mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 14:42:11 +02:00
fix bug 98365 enums nested in structs (C)
This commit is contained in:
parent
77ec35c624
commit
a5ed254394
2 changed files with 18 additions and 1 deletions
|
@ -3143,4 +3143,21 @@ public class AST2Tests extends AST2BaseTest {
|
|||
ITypedef e = (ITypedef) col.getName(2).resolveBinding();
|
||||
assertSame( e.getType(), etion );
|
||||
}
|
||||
|
||||
public void testBug98365() throws Exception {
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
buffer.append("typedef struct _loop_data { \n"); //$NON-NLS-1$
|
||||
buffer.append(" enum { PIPERR } pipe_err; \n"); //$NON-NLS-1$
|
||||
buffer.append("} loop_data; \n"); //$NON-NLS-1$
|
||||
buffer.append("void f(){ \n"); //$NON-NLS-1$
|
||||
buffer.append(" PIPERR; \n"); //$NON-NLS-1$
|
||||
buffer.append("} \n"); //$NON-NLS-1$
|
||||
|
||||
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C, true);
|
||||
CNameCollector col = new CNameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
IEnumerator etor = (IEnumerator) col.getName(2).resolveBinding();
|
||||
assertSame( etor, col.getName(6).resolveBinding() );
|
||||
}
|
||||
}
|
|
@ -1316,7 +1316,7 @@ public class CVisitor {
|
|||
for( int i = 0; i < nested.length; i++ ){
|
||||
if( nested[i] instanceof IASTSimpleDeclaration ){
|
||||
IASTDeclSpecifier d = ((IASTSimpleDeclaration)nested[i]).getDeclSpecifier();
|
||||
if( d instanceof ICASTCompositeTypeSpecifier ) {
|
||||
if( d instanceof ICASTCompositeTypeSpecifier || d instanceof IASTEnumerationSpecifier ) {
|
||||
Object obj = checkForBinding( scope, d, name, typesOnly, prefixMap );
|
||||
if( prefixMap == null && resultName == null ){
|
||||
resultName = (IASTName) obj;
|
||||
|
|
Loading…
Add table
Reference in a new issue