p2.cpp revision 2fe9b7fb07dff15dd15dd8755a9a9e6de0fe46fc
1// RUN: %clang_cc1 -fsyntax-only -verify %s 2 3namespace N { 4 struct X { }; 5 6 X operator+(X, X); 7 8 void f(X); 9 void g(X); // expected-note{{candidate function}} 10 11 void test_multiadd(X x) { 12 (void)(x + x); 13 } 14} 15 16namespace M { 17 struct Y : N::X { }; 18} 19 20void f(); // expected-note 2 {{'f' declared here}} 21 22void test_operator_adl(N::X x, M::Y y) { 23 (void)(x + x); 24 (void)(y + y); 25} 26 27void test_func_adl(N::X x, M::Y y) { 28 f(x); 29 f(y); 30 (f)(x); // expected-error{{too many arguments to function call}} 31 ::f(x); // expected-error{{too many arguments to function call}} 32} 33 34namespace N { 35 void test_multiadd2(X x) { 36 (void)(x + x); 37 } 38} 39 40 41void test_func_adl_only(N::X x) { 42 g(x); 43} 44 45namespace M { 46 int g(N::X); // expected-note{{candidate function}} 47 48 void test(N::X x) { 49 g(x); // expected-error{{call to 'g' is ambiguous}} 50 int i = (g)(x); 51 52 int g(N::X); 53 g(x); // okay; calls locally-declared function, no ADL 54 } 55} 56 57 58void test_operator_name_adl(N::X x) { 59 (void)operator+(x, x); 60} 61 62struct Z { }; 63int& f(Z); 64 65namespace O { 66 char &f(); 67 void test_global_scope_adl(Z z) { 68 { 69 int& ir = f(z); 70 } 71 } 72} 73 74extern "C" { 75 struct L { }; 76} 77 78void h(L); // expected-note{{candidate function}} 79 80namespace P { 81 void h(L); // expected-note{{candidate function}} 82 void test_transparent_context_adl(L l) { 83 { 84 h(l); // expected-error {{call to 'h' is ambiguous}} 85 } 86 } 87} 88 89namespace test5 { 90 namespace NS { 91 struct A; 92 void foo(void (*)(A&)); 93 } 94 void bar(NS::A& a); 95 96 void test() { 97 foo(&bar); 98 } 99} 100 101// PR6762: __builtin_va_list should be invisible to ADL on all platforms. 102void test6_function(__builtin_va_list &argv); 103namespace test6 { 104 void test6_function(__builtin_va_list &argv); 105 106 void test() { 107 __builtin_va_list args; 108 test6_function(args); 109 } 110} 111