1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Fix for 202271, ClassCaseException in name resolution.

This commit is contained in:
Markus Schorn 2007-09-06 15:37:23 +00:00
parent e069b7e8b4
commit 7396f52e19
2 changed files with 19 additions and 1 deletions

View file

@ -86,7 +86,9 @@ import org.eclipse.cdt.core.dom.ast.c.ICASTSimpleDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.c.ICArrayType;
import org.eclipse.cdt.core.dom.ast.c.ICExternalBinding;
import org.eclipse.cdt.core.dom.ast.c.ICFunctionScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
import org.eclipse.cdt.core.parser.ParserLanguage;
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
import org.eclipse.cdt.internal.core.dom.parser.c.CFunction;
@ -3933,4 +3935,19 @@ public class AST2Tests extends AST2BaseTest {
parse( buffer.toString(), ParserLanguage.CPP, true, true );
parse( buffer.toString(), ParserLanguage.C, true, true );
}
// class NameClash {};
// namespace NameClash {};
// namespace NameClash2 {};
// class NameClash2 {};
public void testBug202271_nameClash() throws Exception {
StringBuffer buffer = getContents(1)[0];
IASTTranslationUnit tu= parseAndCheckBindings( buffer.toString(), ParserLanguage.CPP, true );
CNameCollector col = new CNameCollector();
tu.accept(col);
assertInstance(col.getName(0).resolveBinding(), ICPPClassType.class);
assertInstance(col.getName(1).resolveBinding(), ICPPNamespace.class);
assertInstance(col.getName(2).resolveBinding(), ICPPNamespace.class);
assertInstance(col.getName(3).resolveBinding(), ICPPClassType.class);
}
}

View file

@ -418,7 +418,8 @@ public class CPPVisitor {
IBinding binding;
try {
binding = scope.getBinding( namespaceDef.getName(), false );
if( !(binding instanceof ICPPInternalBinding) || binding instanceof IProblemBinding ){
if( !(binding instanceof ICPPInternalBinding) || binding instanceof IProblemBinding
|| !(binding instanceof ICPPNamespace)){
binding = new CPPNamespace( namespaceDef );
ASTInternal.addName( scope, namespaceDef.getName() );
}