From f2bf6c0fa9193779ec7802978fc495014aae069e Mon Sep 17 00:00:00 2001 From: Sergey Prigogin Date: Tue, 17 Feb 2009 02:43:24 +0000 Subject: [PATCH] Test case for bug 265070. --- .../core/parser/tests/ast2/AST2TemplateTests.java | 11 +++++++++++ .../dom/parser/cpp/semantics/CPPSemantics.java | 14 +++++++------- .../core/dom/parser/cpp/semantics/CPPVisitor.java | 4 ++-- 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java index eb29a01bdb6..375a8d78619 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java @@ -3832,4 +3832,15 @@ public class AST2TemplateTests extends AST2BaseTest { String code= getAboveComment(); parseAndCheckBindings(code, ParserLanguage.CPP); } + + // template + // struct A { + // enum E { e }; + // }; + // + // int x = A<0>::e; + public void _testEnumeratorInTemplateInstance_265070() throws Exception { + String code= getAboveComment(); + parseAndCheckBindings(code, ParserLanguage.CPP); + } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java index f3d50d7bdad..188f00f19a6 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java @@ -536,7 +536,7 @@ public class CPPSemantics { } static private void getAssociatedScopes(IType t, ObjectSet namespaces, - ObjectSet classes, CPPASTTranslationUnit tu) throws DOMException{ + ObjectSet classes, CPPASTTranslationUnit tu) throws DOMException { // 3.4.2-2 if (t instanceof ICPPClassType) { ICPPClassType ct= (ICPPClassType) t; @@ -576,7 +576,7 @@ public class CPPSemantics { } static private ICPPNamespaceScope getContainingNamespaceScope(IBinding binding, - CPPASTTranslationUnit tu) throws DOMException{ + CPPASTTranslationUnit tu) throws DOMException { if (binding == null) return null; IScope scope = binding.getScope(); while (scope != null && !(scope instanceof ICPPNamespaceScope)) { @@ -702,7 +702,7 @@ public class CPPSemantics { * @param data the lookup data created off 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); IASTNode blockItem= data.astName; if (blockItem == null) @@ -1050,7 +1050,7 @@ public class CPPSemantics { 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[]) { names = ArrayUtil.trim(Object.class, (Object[]) names); 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 * 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 allNominated= data.usingDirectives.remove(scope); while (allNominated != null) { for (ICPPNamespaceScope nominated : allNominated) { @@ -2620,7 +2620,7 @@ public class CPPSemantics { 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); } @@ -2628,7 +2628,7 @@ public class CPPSemantics { 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(); astName.setName(name); astName.setParent(ASTInternal.getPhysicalNodeOfScope(scope)); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPVisitor.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPVisitor.java index dc8be73fb1a..581e8d32863 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPVisitor.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPVisitor.java @@ -931,7 +931,7 @@ public class CPPVisitor extends ASTQueries { } } if (i > 0) { - IBinding binding = names[i-1].resolveBinding(); + IBinding binding = names[i - 1].resolveBinding(); while (binding instanceof ITypedef) { IType t = ((ITypedef) binding).getType(); if (t instanceof IBinding) @@ -954,7 +954,7 @@ public class CPPVisitor extends ASTQueries { } if (done) { 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; }