46 lines · cpp
1// RUN: %clang_cc1 -std=c++14 -verify %s2// RUN: %clang_cc1 -std=c++14 -verify %s -DHAVE_UNQUALIFIED_LOOKUP_RESULTS3// expected-no-diagnostics4 5namespace address_of {6#ifdef HAVE_UNQUALIFIED_LOOKUP_RESULTS7 struct Q {};8 void operator&(Q);9#endif10 11 template<typename T> struct A {12 static constexpr auto x = &T::value;13 };14 15 template<typename T> struct B {16 constexpr int operator&() { return 123; }17 };18 19 template<typename T> struct C {20 static_assert(sizeof(T) == 123, "");21 };22 23 struct X1 {24 static B<X1> value;25 };26 struct X2 : B<X2> {27 enum E { value };28 friend constexpr int operator&(E) { return 123; }29 };30 31 struct Y1 {32 C<int> *value;33 };34 struct Y2 {35 C<int> value();36 };37 38 // ok, uses ADL to find operator&:39 static_assert(A<X1>::x == 123, "");40 static_assert(A<X2>::x == 123, "");41 42 // ok, does not use ADL so does not instantiate C<T>:43 static_assert(A<Y1>::x == &Y1::value, "");44 static_assert(A<Y2>::x == &Y2::value, "");45}46