blob: 59cc61ca9a4962b19ecbc0cb237405d27bf8cccc [file] [log] [blame]
Argiris Kirtzidis810c0f72008-09-10 02:17:11 +00001// RUN: clang -fsyntax-only -verify %s
2
3void test() {
Argiris Kirtzidisc4e1e452008-09-10 23:34:50 +00004 int x;
5 if (x) ++x;
Argiris Kirtzidis810c0f72008-09-10 02:17:11 +00006 if (int x=0) ++x;
7
8 typedef int arr[10];
9 while (arr x=0) ; // expected-error: {{an array type is not allowed here}} expected-error: {{initialization with "{...}" expected for array}}
10 while (int f()=0) ; // expected-error: {{a function type is not allowed here}}
11
12 struct S {} s;
Argiris Kirtzidisc4e1e452008-09-10 23:34:50 +000013 if (s) ++x; // expected-error: {{expression must have bool type (or be convertible to bool) ('struct S' invalid)}}
Argiris Kirtzidis810c0f72008-09-10 02:17:11 +000014 while (struct S x=s) ; // expected-error: {{expression must have bool type (or be convertible to bool) ('struct S' invalid)}}
15 switch (s) {} // expected-error: {{statement requires expression of integer type ('struct S' invalid)}}
16
17 while (struct S {} x=0) ; // expected-error: {{types may not be defined in conditions}} expected-error: {{incompatible type}} expected-error: {{expression must have bool type}}
18 while (struct {} x=0) ; // expected-error: {{types may not be defined in conditions}} expected-error: {{incompatible type}} expected-error: {{expression must have bool type}}
19 switch (enum {E} x=0) ; // expected-error: {{types may not be defined in conditions}}
20
21 if (int x=0) { // expected-error: {{previous definition is here}}
22 int x; // expected-error: {{redefinition of 'x'}}
23 }
24 else
25 int x; // expected-error: {{redefinition of 'x'}}
26 while (int x=0) int x; // expected-error: {{redefinition of 'x'}} expected-error: {{previous definition is here}}
27 while (int x=0) { int x; } // expected-error: {{redefinition of 'x'}} expected-error: {{previous definition is here}}
28 for (int x; int x=0; ) ; // expected-error: {{redefinition of 'x'}} expected-error: {{previous definition is here}}
29 for (int x; ; ) int x; // expected-error: {{redefinition of 'x'}} expected-error: {{previous definition is here}}
30 for (; int x=0; ) int x; // expected-error: {{redefinition of 'x'}} expected-error: {{previous definition is here}}
31 for (; int x=0; ) { int x; } // expected-error: {{redefinition of 'x'}} expected-error: {{previous definition is here}}
32 switch (int x=0) { default: int x; } // expected-error: {{redefinition of 'x'}} expected-error: {{previous definition is here}}
33}