Program: 92420
Project: 92420
Buggy source:
/** 
 * Parses a struct declaration and returns the corresponding declaration.
 * @param struct An STRUCT node.
 * @return The corresponding struct declaration.
 * @throws ParseException
 */
private StructDeclaration parseStruct(CommonTree struct) throws ParseException {
  assert(struct.getType() == CTFParser.STRUCT);
  List<CommonTree> children=struct.getChildren();
  assert(children != null);
  StructDeclaration structDeclaration=null;
  String structName=null;
  boolean hasName=false;
  CommonTree structBody=null;
  boolean hasBody=false;
  long structAlign=0;
  for (  CommonTree child : children) {
switch (child.getType()) {
case CTFParser.STRUCT_NAME:
{
        hasName=true;
        assert(child.getChildCount() == 1);
        CommonTree structNameIdentifier=(CommonTree)child.getChild(0);
        assert(structNameIdentifier.getType() == CTFParser.IDENTIFIER);
        structName=structNameIdentifier.getText();
        break;
      }
case CTFParser.STRUCT_BODY:
{
      hasBody=true;
      structBody=child;
      break;
    }
case CTFParser.ALIGN:
{
    assert(child.getChildCount() == 1);
    CommonTree structAlignExpression=(CommonTree)child.getChild(0);
    structAlign=getAlignment(structAlignExpression);
    break;
  }
default :
childTypeError(child);
break;
}
}
if (hasBody) {
if (hasName && (getCurrentScope().lookupStruct(structName) != null)) {
throw new ParseException("String_Node_Str" + structName + "String_Node_Str");
}
structDeclaration=new StructDeclaration(structAlign);
parseStructBody(structBody,structDeclaration);
long maxFieldAlign=-1;
for (IDeclaration field : structDeclaration.getFields().values()) {
maxFieldAlign=Math.max(maxFieldAlign,field.getAlignment());
}
structDeclaration.setMinAlign(maxFieldAlign);
if (hasName) {
getCurrentScope().registerStruct(structName,structDeclaration);
}
}
 else {
if (hasName) {
structDeclaration=getCurrentScope().rlookupStruct(structName);
if (structDeclaration == null) {
throw new ParseException("String_Node_Str" + structName + "String_Node_Str");
}
}
 else {
throw new ParseException("String_Node_Str");
}
}
assert(structDeclaration != null);
return structDeclaration;
}

Fixed version (ground truth):
/** 
 * Parses a struct declaration and returns the corresponding declaration.
 * @param struct An STRUCT node.
 * @return The corresponding struct declaration.
 * @throws ParseException
 */
private StructDeclaration parseStruct(CommonTree struct) throws ParseException {
  assert(struct.getType() == CTFParser.STRUCT);
  List<CommonTree> children=struct.getChildren();
  assert(children != null);
  StructDeclaration structDeclaration=null;
  String structName=null;
  boolean hasName=false;
  CommonTree structBody=null;
  boolean hasBody=false;
  long structAlign=0;
  for (  CommonTree child : children) {
switch (child.getType()) {
case CTFParser.STRUCT_NAME:
{
        hasName=true;
        assert(child.getChildCount() == 1);
        CommonTree structNameIdentifier=(CommonTree)child.getChild(0);
        assert(structNameIdentifier.getType() == CTFParser.IDENTIFIER);
        structName=structNameIdentifier.getText();
        break;
      }
case CTFParser.STRUCT_BODY:
{
      hasBody=true;
      structBody=child;
      break;
    }
case CTFParser.ALIGN:
{
    assert(child.getChildCount() == 1);
    CommonTree structAlignExpression=(CommonTree)child.getChild(0);
    structAlign=getAlignment(structAlignExpression);
    break;
  }
default :
childTypeError(child);
break;
}
}
if (hasBody) {
if (hasName && (getCurrentScope().lookupStruct(structName) != null)) {
throw new ParseException("String_Node_Str" + structName + "String_Node_Str");
}
structDeclaration=new StructDeclaration(structAlign);
parseStructBody(structBody,structDeclaration);
if (hasName) {
getCurrentScope().registerStruct(structName,structDeclaration);
}
}
 else {
if (hasName) {
structDeclaration=getCurrentScope().rlookupStruct(structName);
if (structDeclaration == null) {
throw new ParseException("String_Node_Str" + structName + "String_Node_Str");
}
}
 else {
throw new ParseException("String_Node_Str");
}
}
assert(structDeclaration != null);
return structDeclaration;
}