1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-29 20:05:35 +02:00

Bug 506170 - Compute correct associated namespaces for enumeration type

Change-Id: I60ddfd1f98b6f32ad785e8d881704356aff18043
This commit is contained in:
Nathan Ridge 2016-10-28 03:23:45 -04:00
parent 8244bcd33d
commit 6c4576281d
2 changed files with 47 additions and 8 deletions

View file

@ -8123,6 +8123,39 @@ public class AST2TemplateTests extends AST2TestBase {
assertEquals(1, num.longValue()); assertEquals(1, num.longValue());
} }
// template <int>
// struct A {
// void waldo();
// };
//
// template <typename>
// struct traits {
// enum {
// E = 1,
// };
// };
//
// template <typename T>
// struct L {
// enum {
// X = traits<T>::E & 1
// };
// };
//
// template <typename T>
// struct B : A<L<T>::X> {
// using A<L<T>::X>::waldo;
// };
//
// class M : public B<M> {};
//
// void bar(B<M>& v) {
// v.waldo();
// }
public void testArgumentDependentLookupForEnumeration_506170() throws Exception {
parseAndCheckBindings();
}
// template <int...> struct A {}; // template <int...> struct A {};
// template <int... I> void foo(A<I...>); // template <int... I> void foo(A<I...>);
// int main() { // int main() {

View file

@ -788,13 +788,19 @@ public class CPPSemantics {
return; return;
handled.put(t); handled.put(t);
IBinding owner= ((IBinding) t).getOwner(); if (t instanceof IEnumeration) {
if (owner instanceof ICPPClassType) { // [basic.lookup.argdep] p2.3: an enumeration's only associated namespace
getAssociatedScopes((IType) owner, namespaces, friendFns, handled, tu, // is the innermost enclosing namespace of its declaration.
false /* do not look at base classes of the enclosing class */); getAssociatedNamespaceScopes(getContainingNamespaceScope((IBinding) t, tu), namespaces);
} else { } else {
getAssociatedNamespaceScopes(getContainingNamespaceScope((IBinding) t, tu), namespaces); 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)) { if (t instanceof ICPPClassType && !(t instanceof ICPPClassTemplate)) {
ICPPClassType ct= (ICPPClassType) t; ICPPClassType ct= (ICPPClassType) t;