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

Test case for bug 265070.

This commit is contained in:
Sergey Prigogin 2009-02-17 02:43:24 +00:00
parent d1019b8da6
commit f2bf6c0fa9
3 changed files with 20 additions and 9 deletions

View file

@ -3832,4 +3832,15 @@ public class AST2TemplateTests extends AST2BaseTest {
String code= getAboveComment(); String code= getAboveComment();
parseAndCheckBindings(code, ParserLanguage.CPP); parseAndCheckBindings(code, ParserLanguage.CPP);
} }
// template<int V>
// struct A {
// enum E { e };
// };
//
// int x = A<0>::e;
public void _testEnumeratorInTemplateInstance_265070() throws Exception {
String code= getAboveComment();
parseAndCheckBindings(code, ParserLanguage.CPP);
}
} }

View file

@ -536,7 +536,7 @@ public class CPPSemantics {
} }
static private void getAssociatedScopes(IType t, ObjectSet<IScope> namespaces, static private void getAssociatedScopes(IType t, ObjectSet<IScope> namespaces,
ObjectSet<ICPPClassType> classes, CPPASTTranslationUnit tu) throws DOMException{ ObjectSet<ICPPClassType> classes, CPPASTTranslationUnit tu) throws DOMException {
// 3.4.2-2 // 3.4.2-2
if (t instanceof ICPPClassType) { if (t instanceof ICPPClassType) {
ICPPClassType ct= (ICPPClassType) t; ICPPClassType ct= (ICPPClassType) t;
@ -576,7 +576,7 @@ public class CPPSemantics {
} }
static private ICPPNamespaceScope getContainingNamespaceScope(IBinding binding, static private ICPPNamespaceScope getContainingNamespaceScope(IBinding binding,
CPPASTTranslationUnit tu) throws DOMException{ CPPASTTranslationUnit tu) throws DOMException {
if (binding == null) return null; if (binding == null) return null;
IScope scope = binding.getScope(); IScope scope = binding.getScope();
while (scope != null && !(scope instanceof ICPPNamespaceScope)) { while (scope != null && !(scope instanceof ICPPNamespaceScope)) {
@ -702,7 +702,7 @@ public class CPPSemantics {
* @param data the lookup data created off a name * @param data the lookup data created off a name
* @param start either a scope or a name. * @param start either a scope or a name.
*/ */
static protected void lookup(LookupData data, Object start) throws DOMException{ static protected void lookup(LookupData data, Object start) throws DOMException {
final IIndexFileSet fileSet= getIndexFileSet(data); final IIndexFileSet fileSet= getIndexFileSet(data);
IASTNode blockItem= data.astName; IASTNode blockItem= data.astName;
if (blockItem == null) if (blockItem == null)
@ -1050,7 +1050,7 @@ public class CPPSemantics {
data.inheritanceChain.remove(scope); data.inheritanceChain.remove(scope);
} }
private static boolean checkForAmbiguity(LookupData data, Object n, Object names) throws DOMException{ private static boolean checkForAmbiguity(LookupData data, Object n, Object names) throws DOMException {
if (names instanceof Object[]) { if (names instanceof Object[]) {
names = ArrayUtil.trim(Object.class, (Object[]) names); names = ArrayUtil.trim(Object.class, (Object[]) names);
if (((Object[])names).length == 0) if (((Object[])names).length == 0)
@ -1465,7 +1465,7 @@ public class CPPSemantics {
* that transitive directives have been stored in the lookup-data. For qualified lookups the transitive directives * that transitive directives have been stored in the lookup-data. For qualified lookups the transitive directives
* are considered if the lookup of the original directive returns empty. * are considered if the lookup of the original directive returns empty.
*/ */
static private void lookupInNominated(LookupData data, ICPPNamespaceScope scope) throws DOMException{ static private void lookupInNominated(LookupData data, ICPPNamespaceScope scope) throws DOMException {
List<ICPPNamespaceScope> allNominated= data.usingDirectives.remove(scope); List<ICPPNamespaceScope> allNominated= data.usingDirectives.remove(scope);
while (allNominated != null) { while (allNominated != null) {
for (ICPPNamespaceScope nominated : allNominated) { for (ICPPNamespaceScope nominated : allNominated) {
@ -2620,7 +2620,7 @@ public class CPPSemantics {
return null; return null;
} }
public static IBinding[] findBindings(IScope scope, String name, boolean qualified) throws DOMException{ public static IBinding[] findBindings(IScope scope, String name, boolean qualified) throws DOMException {
return findBindings(scope, name.toCharArray(), qualified, null); return findBindings(scope, name.toCharArray(), qualified, null);
} }
@ -2628,7 +2628,7 @@ public class CPPSemantics {
return findBindings(scope, name, qualified, null); return findBindings(scope, name, qualified, null);
} }
public static IBinding[] findBindings(IScope scope, char[] name, boolean qualified, IASTNode beforeNode) throws DOMException{ public static IBinding[] findBindings(IScope scope, char[] name, boolean qualified, IASTNode beforeNode) throws DOMException {
CPPASTName astName = new CPPASTName(); CPPASTName astName = new CPPASTName();
astName.setName(name); astName.setName(name);
astName.setParent(ASTInternal.getPhysicalNodeOfScope(scope)); astName.setParent(ASTInternal.getPhysicalNodeOfScope(scope));

View file

@ -931,7 +931,7 @@ public class CPPVisitor extends ASTQueries {
} }
} }
if (i > 0) { if (i > 0) {
IBinding binding = names[i-1].resolveBinding(); IBinding binding = names[i - 1].resolveBinding();
while (binding instanceof ITypedef) { while (binding instanceof ITypedef) {
IType t = ((ITypedef) binding).getType(); IType t = ((ITypedef) binding).getType();
if (t instanceof IBinding) if (t instanceof IBinding)
@ -954,7 +954,7 @@ public class CPPVisitor extends ASTQueries {
} }
if (done) { if (done) {
if (scope == null) { if (scope == null) {
return new CPPScope.CPPScopeProblem(names[i-1], IProblemBinding.SEMANTIC_BAD_SCOPE); return new CPPScope.CPPScopeProblem(names[i - 1], IProblemBinding.SEMANTIC_BAD_SCOPE);
} }
return scope; return scope;
} }