1 // RUN: clang-cc -fsyntax-only -verify %s
2 
3 namespace 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 
16 namespace M {
17   struct Y : N::X { };
18 }
19 
20 void f();
21 
22 void test_operator_adl(N::X x, M::Y y) {
23   (void)(x + x);
24   (void)(y + y);
25 }
26 
27 void 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 
34 namespace N {
35   void test_multiadd2(X x) {
36     (void)(x + x);
37   }
38 }
39 
40 
41 void test_func_adl_only(N::X x) {
42   g(x);
43 }
44 
45 namespace 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; candidates are:}}
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 
58 void test_operator_name_adl(N::X x) {
59   (void)operator+(x, x);
60 }
61 
62 struct Z { };
63 int& f(Z);
64 
65 namespace O {
66   char &f();
67   void test_global_scope_adl(Z z) {
68     {
69       int& ir = f(z);
70     }
71   }
72 }
73 
74