mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
bug 54639 Typedef of enumeration fails complete parse
This commit is contained in:
parent
fbb3c4c84d
commit
2d45963863
2 changed files with 26 additions and 0 deletions
|
@ -17,6 +17,7 @@ import java.util.Iterator;
|
|||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||
import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
|
||||
import org.eclipse.cdt.core.parser.ast.ASTClassKind;
|
||||
import org.eclipse.cdt.core.parser.ast.ASTPointerOperator;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTASMDefinition;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTAbstractTypeSpecifierDeclaration;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTBaseSpecifier;
|
||||
|
@ -1281,4 +1282,24 @@ public class CompleteParseASTTest extends CompleteParseBaseTest
|
|||
assertFalse( i.hasNext() );
|
||||
}
|
||||
|
||||
public void testBug54639() throws Exception
|
||||
{
|
||||
Writer writer = new StringWriter();
|
||||
writer.write( "typedef enum _A { } A, *pA; " );
|
||||
|
||||
Iterator i = parse( writer.toString() ).getDeclarations();
|
||||
|
||||
IASTTypedefDeclaration typedef = (IASTTypedefDeclaration)i.next();
|
||||
assertEquals( typedef.getName(), "A" );
|
||||
IASTEnumerationSpecifier enumSpec = (IASTEnumerationSpecifier) typedef.getAbstractDeclarator().getTypeSpecifier();
|
||||
assertEquals( enumSpec.getName(), "_A" );
|
||||
|
||||
IASTTypedefDeclaration typedef2 = (IASTTypedefDeclaration)i.next();
|
||||
assertEquals( typedef2.getName(), "pA" );
|
||||
assertEquals( typedef2.getAbstractDeclarator().getPointerOperators().next(), ASTPointerOperator.POINTER );
|
||||
enumSpec = (IASTEnumerationSpecifier) typedef2.getAbstractDeclarator().getTypeSpecifier();
|
||||
assertEquals( enumSpec.getName(), "_A" );
|
||||
|
||||
assertFalse( i.hasNext() );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2329,6 +2329,11 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
symbolToBeCloned.setTypeSymbol(elab.getSymbol());
|
||||
if( elab.getSymbol() != null )
|
||||
references.add( createReference( elab.getSymbol(), elab.getName(), elab.getNameOffset()) );
|
||||
}
|
||||
else if ( abstractDeclaration.getTypeSpecifier() instanceof ASTEnumerationSpecifier )
|
||||
{
|
||||
symbolToBeCloned = pst.newSymbol( name, TypeInfo.t_type );
|
||||
symbolToBeCloned.setTypeSymbol(((ASTEnumerationSpecifier)abstractDeclaration.getTypeSpecifier()).getSymbol());
|
||||
}
|
||||
newSymbol = (ISymbol) symbolToBeCloned.clone();
|
||||
newSymbol.setName( name );
|
||||
|
|
Loading…
Add table
Reference in a new issue