1 // RUN: %clang_cc1 -std=c++14 -verify %s
2 // RUN: %clang_cc1 -std=c++14 -verify %s -DHAVE_UNQUALIFIED_LOOKUP_RESULTS
3 // expected-no-diagnostics
4 
5 namespace address_of {
6 #ifdef HAVE_UNQUALIFIED_LOOKUP_RESULTS
7   struct Q {};
8   void operator&(Q);
9 #endif
10 
11   template<typename T> struct A {
12     static constexpr auto x = &T::value;
13   };
14 
15   template<typename T> struct B {
operator &address_of::B16     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 };
operator &(E)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