Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix struct declaration introducing name in namespace scope (#587)
When AST is used to resolve binding for class-name and elaborated-type-specifier is found matching [basic.lookup.elab] rule introducing the class-name, behavior of CPPSemantics.resolveAmbiguities() is different in presence of index. If there is no index, CPPVisitor.createBinding() for ICPPASTElaboratedTypeSpecifier creates binding for class-name as introducing the name. When later lookup finds this binding all is good because binding is declared before the use site. If index is available, lookup for class-name fails in AST too but now matching entry is found in the AST index. When later lookup finds this index binding CPPSemantics.declaredBefore() returns false because it does not look in AST index and only checks project index. To fix this additionally check if ICPPClassType object is in AST index, as we already do for ICPPConstructor. This way declaredBefore() does almost the same thing as isReachableFromAst() and lookup succeeds returning the same binding from index.
- Loading branch information