1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-08 10:16:03 +02:00

Patch for Bug 173874 - day one bug in getNestedClasses in CPPClassType. The binding didn't get cleared when moving to the next member.

This commit is contained in:
Doug Schaefer 2007-02-14 16:15:12 +00:00
parent e466f136ac
commit cb85bd81a9
2 changed files with 17 additions and 4 deletions

View file

@ -2654,4 +2654,16 @@ public class CompleteParser2Tests extends TestCase {
assertInstances(col, bar, 1);
}
public void test173874_nestedClasses() throws Exception {
String code = "class aClass { class bClass; int x; };";
IASTTranslationUnit tu = parse(code, true, ParserLanguage.CPP, true);
CPPNameCollector col = new CPPNameCollector();
tu.accept(col);
ICPPClassType cls = (ICPPClassType)col.getName(0).resolveBinding();
ICPPClassType[] nested = cls.getNestedClasses();
assertEquals(1, nested.length);
}
}

View file

@ -793,7 +793,7 @@ public class CPPClassType extends PlatformObject implements ICPPClassType, ICPPI
return new ICPPClassType[] { new CPPClassTypeProblem( node, IProblemBinding.SEMANTIC_DEFINITION_NOT_FOUND, getNameCharArray() ) };
}
}
IBinding binding = null;
ICPPClassType [] result = null;
IASTDeclaration [] decls = getCompositeTypeSpecifier().getMembers();
@ -801,12 +801,13 @@ public class CPPClassType extends PlatformObject implements ICPPClassType, ICPPI
IASTDeclaration decl = decls[i];
while( decl instanceof ICPPASTTemplateDeclaration )
decl = ((ICPPASTTemplateDeclaration)decl).getDeclaration();
if( decls[i] instanceof IASTSimpleDeclaration ){
IASTDeclSpecifier declSpec = ((IASTSimpleDeclaration) decls[i]).getDeclSpecifier();
if( decl instanceof IASTSimpleDeclaration ){
IBinding binding = null;
IASTDeclSpecifier declSpec = ((IASTSimpleDeclaration) decl).getDeclSpecifier();
if( declSpec instanceof ICPPASTCompositeTypeSpecifier ){
binding = ((ICPPASTCompositeTypeSpecifier)declSpec).getName().resolveBinding();
} else if( declSpec instanceof ICPPASTElaboratedTypeSpecifier &&
((IASTSimpleDeclaration)decls[i]).getDeclarators().length == 0 )
((IASTSimpleDeclaration)decl).getDeclarators().length == 0 )
{
binding = ((ICPPASTElaboratedTypeSpecifier)declSpec).getName().resolveBinding();
}