| 1 |
// PR c++/25814 |
| 2 |
// { dg-do compile } |
| 3 |
// Test -Wvexing-parse. |
| 4 |
|
| 5 |
struct T { }; |
| 6 |
|
| 7 |
struct X { |
| 8 |
X(); |
| 9 |
}; |
| 10 |
|
| 11 |
struct S { |
| 12 |
S(int); |
| 13 |
S foo (int (int)); |
| 14 |
S(T); |
| 15 |
int m; |
| 16 |
}; |
| 17 |
|
| 18 |
struct W { |
| 19 |
W(); |
| 20 |
W(X, X); |
| 21 |
int m; |
| 22 |
}; |
| 23 |
|
| 24 |
int g; |
| 25 |
int g1(int(g)); |
| 26 |
int g2(int()); |
| 27 |
void fg(int); |
| 28 |
|
| 29 |
void |
| 30 |
fn1 (double (a)) |
| 31 |
{ |
| 32 |
extern int f0(); |
| 33 |
extern int f1(int(a)); |
| 34 |
int f2(int(a)); // { dg-warning "parentheses were disambiguated as a function declaration" } |
| 35 |
int (*f3)(int(a)); |
| 36 |
int f4(int a); |
| 37 |
int f5(int()); // { dg-warning "parentheses were disambiguated as a function declaration" } |
| 38 |
int f6(...); |
| 39 |
int f7((int(a))); |
| 40 |
int (f8); |
| 41 |
int f9(S(s)); // { dg-warning "parentheses were disambiguated as a function declaration" } |
| 42 |
int(f10) __attribute__(()); |
| 43 |
int(f11(int())); |
| 44 |
if (int(a) = 1) { } |
| 45 |
int j, k, l(); // { dg-warning "empty parentheses were disambiguated as a function declaration" } |
| 46 |
int m, f12(int(j)); // { dg-warning "parentheses were disambiguated as a function declaration" } |
| 47 |
|
| 48 |
T t1(); // { dg-warning "empty parentheses were disambiguated as a function declaration" } |
| 49 |
T t2(T()); // { dg-warning "parentheses were disambiguated as a function declaration" } |
| 50 |
/* Declares a variable t3. */ |
| 51 |
T(t3); |
| 52 |
T t4(), // { dg-warning "empty parentheses were disambiguated as a function declaration" } |
| 53 |
t5(); // { dg-warning "empty parentheses were disambiguated as a function declaration" } |
| 54 |
|
| 55 |
extern S s1(int(a)); |
| 56 |
S s2(int(a)); // { dg-warning "parentheses were disambiguated as a function declaration" } |
| 57 |
S s3(int a); |
| 58 |
S s4(int()); // { dg-warning "parentheses were disambiguated as a function declaration" } |
| 59 |
S s5(int(int)); // { dg-warning "parentheses were disambiguated as a function declaration" } |
| 60 |
S s6(...); |
| 61 |
S s7((int(a))); |
| 62 |
S s8((int)a); |
| 63 |
S s9 = int(a); |
| 64 |
S(T()); |
| 65 |
S s10(S()); // { dg-warning "parentheses were disambiguated as a function declaration" } |
| 66 |
S s11(T()); |
| 67 |
S s12(X()); // { dg-warning "parentheses were disambiguated as a function declaration" } |
| 68 |
S s13 = S(T()); |
| 69 |
S(T()).foo(0); |
| 70 |
S (S::*foo)(int (int)); |
| 71 |
S(*s14)(int(a)); |
| 72 |
S s15(); // { dg-warning "empty parentheses were disambiguated as a function declaration" } |
| 73 |
S s16(void); |
| 74 |
|
| 75 |
/* Don't warn here. */ |
| 76 |
void fv1(int(a)); |
| 77 |
void fv2(int()); |
| 78 |
void (fv3)(); |
| 79 |
void (fv4)(void); |
| 80 |
void (fv5)(int); |
| 81 |
|
| 82 |
int n(); // { dg-warning "empty parentheses were disambiguated as a function declaration" } |
| 83 |
int (n2)(); // { dg-warning "empty parentheses were disambiguated as a function declaration" } |
| 84 |
int n3(void); |
| 85 |
|
| 86 |
typedef int F(const char*); |
| 87 |
typedef int F2(); |
| 88 |
typedef int F3() const; |
| 89 |
typedef int F4(int(a)) const; |
| 90 |
|
| 91 |
W w(X(), X()); // { dg-warning "parentheses were disambiguated as a function declaration" } |
| 92 |
} |
| 93 |
|
| 94 |
struct C1 { |
| 95 |
C1(int); |
| 96 |
}; |
| 97 |
|
| 98 |
struct C2 { |
| 99 |
C2(C1, int); |
| 100 |
}; |
| 101 |
|
| 102 |
template<int N> int value() { return N; } |
| 103 |
|
| 104 |
void |
| 105 |
fn2 () |
| 106 |
{ |
| 107 |
int i = 0; |
| 108 |
C2 c2(C1(int(i)), i); |
| 109 |
C1(value<0>()); |
| 110 |
} |