mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-23 00:45:28 +02:00
fix for anonymous structures
This commit is contained in:
parent
0d49540c18
commit
10213ebf8a
2 changed files with 24 additions and 2 deletions
|
@ -4718,4 +4718,25 @@ public class AST2CPPTests extends AST2BaseTest {
|
|||
ICPPMethod f = (ICPPMethod) col.getName(9).resolveBinding();
|
||||
assertSame( f, col.getName(11).resolveBinding() );
|
||||
}
|
||||
|
||||
public void testAnonymousStructures() throws Exception {
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
buffer.append("struct A { \n");
|
||||
buffer.append(" struct { int i; } B; \n");
|
||||
buffer.append(" struct { int j; } C; \n");
|
||||
buffer.append("}; \n");
|
||||
buffer.append("void f(){ \n");
|
||||
buffer.append(" A a; \n");
|
||||
buffer.append(" a.B.i; a.C.j; \n");
|
||||
buffer.append("} \n");
|
||||
|
||||
IASTTranslationUnit tu = parse( buffer.toString(), ParserLanguage.CPP );
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
ICPPField i = (ICPPField) col.getName(12).resolveBinding();
|
||||
ICPPField j = (ICPPField) col.getName(15).resolveBinding();
|
||||
assertSame( i, col.getName(2).resolveBinding() );
|
||||
assertSame( j, col.getName(5).resolveBinding() );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -374,12 +374,13 @@ public class CPPVisitor {
|
|||
}
|
||||
scope = parentScope;
|
||||
}
|
||||
IBinding binding;
|
||||
IBinding binding = null;
|
||||
if( name instanceof ICPPASTTemplateId ){
|
||||
return CPPTemplates.createClassSpecialization( compType );
|
||||
}
|
||||
try {
|
||||
binding = (scope != null ) ? scope.getBinding( name, false ) : null;
|
||||
if( name.toCharArray().length > 0 && scope != null ) //can't lookup anonymous things
|
||||
binding = scope.getBinding( name, false );
|
||||
if( binding == null || !(binding instanceof ICPPClassType) ){
|
||||
if( template )
|
||||
binding = new CPPClassTemplate( name );
|
||||
|
|
Loading…
Add table
Reference in a new issue