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 46283bd5219..1697054a84a 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 @@ -8123,6 +8123,39 @@ public class AST2TemplateTests extends AST2TestBase { assertEquals(1, num.longValue()); } + // template + // struct A { + // void waldo(); + // }; + // + // template + // struct traits { + // enum { + // E = 1, + // }; + // }; + // + // template + // struct L { + // enum { + // X = traits::E & 1 + // }; + // }; + // + // template + // struct B : A::X> { + // using A::X>::waldo; + // }; + // + // class M : public B {}; + // + // void bar(B& v) { + // v.waldo(); + // } + public void testArgumentDependentLookupForEnumeration_506170() throws Exception { + parseAndCheckBindings(); + } + // template struct A {}; // template void foo(A); // int main() { 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 77fed825f64..d75ed6a77c4 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 @@ -787,14 +787,20 @@ public class CPPSemantics { if (handled.containsKey(t)) return; handled.put(t); - - IBinding owner= ((IBinding) t).getOwner(); - if (owner instanceof ICPPClassType) { - getAssociatedScopes((IType) owner, namespaces, friendFns, handled, tu, - false /* do not look at base classes of the enclosing class */); - } else { - getAssociatedNamespaceScopes(getContainingNamespaceScope((IBinding) t, tu), namespaces); - } + + if (t instanceof IEnumeration) { + // [basic.lookup.argdep] p2.3: an enumeration's only associated namespace + // is the innermost enclosing namespace of its declaration. + getAssociatedNamespaceScopes(getContainingNamespaceScope((IBinding) t, tu), namespaces); + } else { + IBinding owner= ((IBinding) t).getOwner(); + if (owner instanceof ICPPClassType) { + getAssociatedScopes((IType) owner, namespaces, friendFns, handled, tu, + false /* do not look at base classes of the enclosing class */); + } else { + getAssociatedNamespaceScopes(getContainingNamespaceScope((IBinding) t, tu), namespaces); + } + } } if (t instanceof ICPPClassType && !(t instanceof ICPPClassTemplate)) { ICPPClassType ct= (ICPPClassType) t;