Daniel Dunbar | d7d5f02 | 2009-03-24 02:24:46 +0000 | [diff] [blame] | 1 | // RUN: clang-cc -fsyntax-only -verify %s |
Douglas Gregor | fa04764 | 2009-02-04 00:32:51 +0000 | [diff] [blame] | 2 | |
| 3 | namespace N { |
| 4 | struct X { }; |
| 5 | |
| 6 | X operator+(X, X); |
| 7 | |
| 8 | void f(X); |
Douglas Gregor | 1733001 | 2009-02-04 15:01:18 +0000 | [diff] [blame] | 9 | void g(X); // expected-note{{candidate function}} |
Douglas Gregor | fa04764 | 2009-02-04 00:32:51 +0000 | [diff] [blame] | 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) { |
Douglas Gregor | 1733001 | 2009-02-04 15:01:18 +0000 | [diff] [blame] | 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); |
Douglas Gregor | fa04764 | 2009-02-04 00:32:51 +0000 | [diff] [blame] | 60 | } |