Douglas Gregor | fa04764 | 2009-02-04 00:32:51 +0000 | [diff] [blame^] | 1 | // RUN: clang -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); |
| 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 | // FIXME: here, despite the fact that the name lookup for 'g' fails, |
| 43 | // this is well-formed code. The fix will go into Sema::ActOnCallExpr. |
| 44 | // g(x); |
| 45 | } |