| 1 |
// { dg-do assemble } |
| 2 |
// GROUPS passed rtti |
| 3 |
// Negative testcase for decls in conditions. |
| 4 |
|
| 5 |
int main() |
| 6 |
{ |
| 7 |
float i; |
| 8 |
|
| 9 |
if (int i = 1) // { dg-message "previously" } |
| 10 |
{ |
| 11 |
char i; // { dg-error "redeclaration" } |
| 12 |
char j; |
| 13 |
} |
| 14 |
else |
| 15 |
{ |
| 16 |
short i; // { dg-error "redeclaration" } |
| 17 |
char j; |
| 18 |
} |
| 19 |
|
| 20 |
while (int i = 0) // { dg-message "previously" } |
| 21 |
{ |
| 22 |
int i; // { dg-error "redeclaration" } |
| 23 |
} |
| 24 |
|
| 25 |
for (; int i = 0; ) // { dg-message "previously" } |
| 26 |
{ |
| 27 |
int i; // { dg-error "redeclaration" } |
| 28 |
} |
| 29 |
|
| 30 |
switch (int i = 0) // { dg-message "previously" } |
| 31 |
{ |
| 32 |
default: |
| 33 |
int i; // { dg-error "redeclaration" } |
| 34 |
} |
| 35 |
|
| 36 |
if (struct A { operator int () { return 1; } } *foo = new A) // { dg-error "defined" } |
| 37 |
; |
| 38 |
|
| 39 |
A bar; // { dg-error "not declared" "decl" } |
| 40 |
|
| 41 |
if (enum A { one, two, three } foo = one) // { dg-error "defined" "def" } |
| 42 |
// { dg-error "not declared" "expected" { target *-*-* } .-1 } |
| 43 |
; |
| 44 |
|
| 45 |
struct B { operator int () { return 2; } }; |
| 46 |
|
| 47 |
if (struct B * foo = new B) |
| 48 |
; |
| 49 |
|
| 50 |
if (int f () = 1) // { dg-error "declares a function" } |
| 51 |
; |
| 52 |
|
| 53 |
if (int a[2] = {1, 2}) // { dg-error "declares an array" } |
| 54 |
; |
| 55 |
|
| 56 |
} |