blob: 486a688d9437f61f3d9fcf3555ec76dc74916e81 [file] [log] [blame]
Daniel Dunbard7d5f022009-03-24 02:24:46 +00001// RUN: clang-cc -fsyntax-only -verify %s
Douglas Gregorfa047642009-02-04 00:32:51 +00002
3namespace N {
4 struct X { };
5
6 X operator+(X, X);
7
8 void f(X);
Douglas Gregor17330012009-02-04 15:01:18 +00009 void g(X); // expected-note{{candidate function}}
Douglas Gregorfa047642009-02-04 00:32:51 +000010
11 void test_multiadd(X x) {
12 (void)(x + x);
13 }
14}
15
16namespace M {
17 struct Y : N::X { };
18}
19
20void f();
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) {
Douglas Gregor17330012009-02-04 15:01:18 +000042 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; 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
58void test_operator_name_adl(N::X x) {
59 (void)operator+(x, x);
Douglas Gregorfa047642009-02-04 00:32:51 +000060}