/cp
[official-gcc.git] / gcc / testsuite / g++.old-deja / g++.jason / cond.C
blobf9287090fb2949fa6135432b7a46c72e524198f6
1 // { dg-do assemble  }
2 // GROUPS passed rtti
3 // Negative testcase for decls in conditions.
5 int main()
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     }
20   while (int i = 0)             // { dg-message "previously" }
21     {
22       int i;                    // { dg-error "redeclaration" }
23     }
25   for (; int i = 0; )           // { dg-message "previously" }
26     {
27       int i;                    // { dg-error "redeclaration" }
28     }
30   switch (int i = 0)            // { dg-message "previously" }
31     {
32     default:
33       int i;                    // { dg-error "redeclaration" } 
34     }
36   if (struct A { operator int () { return 1; } } *foo = new A) // { dg-error "defined" } 
37     ;
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     ;
45   struct B { operator int () { return 2; } };
47   if (struct B * foo = new B)
48     ;
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     ;