1 // RUN: %clang_cc1 -fsyntax-only -verify %s 2 // RUN: %clang_cc1 -std=c++17 -fsyntax-only -verify %s 3 // RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify %s 4 5 typedef int fn; 6 7 namespace N0 { 8 struct A { 9 friend void fn(); gN0::A10 void g() { 11 int i = fn(1); 12 } 13 }; 14 } 15 16 namespace N1 { 17 struct A { 18 friend void fn(A &); 19 operator int(); gN1::A20 void g(A a) { 21 // ADL should not apply to the lookup of 'fn', it refers to the typedef 22 // above. 23 int i = fn(a); 24 } 25 }; 26 } 27 28 namespace std_example { 29 int h; // expected-note {{non-template declaration}} 30 void g(); 31 #if __cplusplus <= 201703L 32 // expected-note@-2 {{non-template declaration}} 33 #endif 34 namespace N { 35 struct A {}; 36 template<class T> int f(T); 37 template<class T> int g(T); 38 #if __cplusplus <= 201703L 39 // expected-note@-2 {{here}} 40 #endif 41 template<class T> int h(T); // expected-note {{here}} 42 } 43 44 int x = f<N::A>(N::A()); 45 #if __cplusplus <= 201703L 46 // expected-warning@-2 {{C++20 extension}} 47 #endif 48 int y = g<N::A>(N::A()); 49 #if __cplusplus <= 201703L 50 // expected-error@-2 {{'g' does not name a template but is followed by template arguments; did you mean 'N::g'?}} 51 #endif 52 int z = h<N::A>(N::A()); // expected-error {{'h' does not name a template but is followed by template arguments; did you mean 'N::h'?}} 53 } 54 55 namespace AnnexD_example { 56 struct A {}; 57 void operator<(void (*fp)(), A); f()58 void f() {} main()59 int main() { 60 A a; 61 f < a; 62 #if __cplusplus > 201703L 63 // expected-error@-2 {{expected '>'}} expected-note@-2 {{to match this '<'}} 64 #endif 65 (f) < a; 66 } 67 } 68