Douglas Gregor | 6d507a6 | 2009-05-07 17:50:16 +0000 | [diff] [blame] | 1 | // RUN: clang-cc -fsyntax-only -pedantic -verify %s |
| 2 | |
| 3 | // [dcl.ambig.res]p1: |
| 4 | struct S { |
| 5 | S(int); |
| 6 | void bar(); |
| 7 | }; |
| 8 | |
| 9 | int returns_an_int(); |
| 10 | |
| 11 | void foo(double a) |
| 12 | { |
| 13 | S w(int(a)); // expected-warning{{disambiguated}} |
| 14 | w(17); |
| 15 | S x(int()); // expected-warning{{disambiguated}} |
| 16 | x(&returns_an_int); |
| 17 | S y((int)a); |
| 18 | y.bar(); |
| 19 | S z = int(a); |
| 20 | z.bar(); |
| 21 | } |
| 22 | |
| 23 | // [dcl.ambig.res]p3: |
| 24 | char *p; |
| 25 | void *operator new(__SIZE_TYPE__, int); |
| 26 | void foo3() { |
| 27 | const int x = 63; |
| 28 | new (int(*p)) int; //new-placement expression |
| 29 | new (int(*[x])); //new type-id |
| 30 | } |
| 31 | |
| 32 | // [dcl.ambig.res]p4: |
| 33 | template <class T> // expected-note{{here}} |
| 34 | struct S4 { |
| 35 | T *p; |
| 36 | }; |
| 37 | S4<int()> x; //type-id |
| 38 | S4<int(1)> y; // expected-error{{must be a type}} |
| 39 | |
| 40 | // [dcl.ambig.res]p5: |
| 41 | void foo5() |
| 42 | { |
| 43 | (void)sizeof(int(1)); //expression |
| 44 | // FIXME: should we make this an error rather than a warning? |
| 45 | // (It affects SFINAE) |
| 46 | (void)sizeof(int()); // expected-warning{{function type}} |
| 47 | } |
| 48 | |
| 49 | // [dcl.ambig.res]p6: |
| 50 | void foo6() |
| 51 | { |
| 52 | (void)(int(1)); //expression |
Sebastian Redl | 9cc11e7 | 2009-07-25 15:41:38 +0000 | [diff] [blame] | 53 | (void)(int())1; // expected-error{{to 'int ()'}} |
Douglas Gregor | 6d507a6 | 2009-05-07 17:50:16 +0000 | [diff] [blame] | 54 | } |
| 55 | |
| 56 | // [dcl.ambig.res]p7: |
| 57 | class C7 { }; |
| 58 | void f7(int(C7)) { } // expected-note{{candidate}} |
| 59 | int g7(C7); |
| 60 | void foo7() { |
| 61 | f7(1); // expected-error{{no matching function}} |
| 62 | f7(g7); //OK |
| 63 | } |
| 64 | |
| 65 | void h7(int *(C7[10])) { } // expected-note{{previous}} |
| 66 | void h7(int *(*_fp)(C7 _parm[10])) { } // expected-error{{redefinition}} |
Argyrios Kyrtzidis | 1e05421 | 2009-07-21 17:05:03 +0000 | [diff] [blame] | 67 | |
| 68 | struct S5 { |
| 69 | static bool const value = false; |
| 70 | }; |
| 71 | int foo8() { |
| 72 | int v(int(S5::value)); // expected-warning{{disambiguated}} expected-error{{parameter declarator cannot be qualified}} |
| 73 | } |