Files
clang-p2996/clang/test/SemaCXX/adl.cpp
Richard Smith 58bd01fcb6 PR40329: [adl] Fix determination of associated classes when searching a
member enum and then its enclosing class.

There are situations where ADL will collect a class but not the complete
set of associated classes / namespaces of that class. When that
happened, and we later tried to collect those associated classes /
namespaces, we would previously short-circuit the lookup and not find
them. Eg, for:

  struct A : B { enum E; };

if we first looked for associated classes/namespaces of A::E, we'd find
only A. But if we then tried to also collect associated
classes/namespaces of A (which should include the base class B), we
would not add B because we had already visited A.

This also fixes a minor issue where we would fail to collect associated
classes from an overloaded class member access expression naming a
static member function.

llvm-svn: 351382
2019-01-16 22:01:39 +00:00

21 lines
560 B
C++

// RUN: %clang_cc1 -std=c++11 -verify %s
namespace PR40329 {
struct A {
A(int);
friend int operator->*(A, A);
};
struct B : A {
B();
enum E { e };
};
// Associated classes for B are {B, A}
// Associated classes for B::E are {B} (non-transitive in this case)
//
// If we search B::E first, we must not mark B "visited" and shortcircuit
// visiting it later, or we won't find the associated class A.
int k0 = B::e ->* B::e; // expected-error {{non-pointer-to-member type}}
int k1 = B::e ->* B();
int k2 = B() ->* B::e;
}