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