Argiris Kirtzidis | 810c0f7 | 2008-09-10 02:17:11 +0000 | [diff] [blame] | 1 | // RUN: clang -fsyntax-only -verify %s |
| 2 | |
| 3 | void test() { |
Argiris Kirtzidis | c4e1e45 | 2008-09-10 23:34:50 +0000 | [diff] [blame] | 4 | int x; |
| 5 | if (x) ++x; |
Argiris Kirtzidis | 810c0f7 | 2008-09-10 02:17:11 +0000 | [diff] [blame] | 6 | 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 Kirtzidis | c4e1e45 | 2008-09-10 23:34:50 +0000 | [diff] [blame] | 13 | if (s) ++x; // expected-error: {{expression must have bool type (or be convertible to bool) ('struct S' invalid)}} |
Argiris Kirtzidis | 810c0f7 | 2008-09-10 02:17:11 +0000 | [diff] [blame] | 14 | while (struct S x=s) ; // expected-error: {{expression must have bool type (or be convertible to bool) ('struct S' invalid)}} |
Argiris Kirtzidis | c362d38 | 2008-09-11 05:16:22 +0000 | [diff] [blame^] | 15 | do ; while (s); // expected-error: {{expression must have bool type (or be convertible to bool) ('struct S' invalid)}} |
| 16 | for (;s;) ; // expected-error: {{expression must have bool type (or be convertible to bool) ('struct S' invalid)}} |
Argiris Kirtzidis | 810c0f7 | 2008-09-10 02:17:11 +0000 | [diff] [blame] | 17 | switch (s) {} // expected-error: {{statement requires expression of integer type ('struct S' invalid)}} |
| 18 | |
| 19 | 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}} |
| 20 | while (struct {} x=0) ; // expected-error: {{types may not be defined in conditions}} expected-error: {{incompatible type}} expected-error: {{expression must have bool type}} |
| 21 | switch (enum {E} x=0) ; // expected-error: {{types may not be defined in conditions}} |
| 22 | |
| 23 | if (int x=0) { // expected-error: {{previous definition is here}} |
| 24 | int x; // expected-error: {{redefinition of 'x'}} |
| 25 | } |
| 26 | else |
| 27 | int x; // expected-error: {{redefinition of 'x'}} |
| 28 | while (int x=0) int x; // expected-error: {{redefinition of 'x'}} expected-error: {{previous definition is here}} |
| 29 | while (int x=0) { int x; } // expected-error: {{redefinition of 'x'}} expected-error: {{previous definition is here}} |
| 30 | for (int x; int x=0; ) ; // expected-error: {{redefinition of 'x'}} expected-error: {{previous definition is here}} |
| 31 | for (int x; ; ) int x; // expected-error: {{redefinition of 'x'}} expected-error: {{previous definition is here}} |
| 32 | for (; int x=0; ) int x; // expected-error: {{redefinition of 'x'}} expected-error: {{previous definition is here}} |
| 33 | for (; int x=0; ) { int x; } // expected-error: {{redefinition of 'x'}} expected-error: {{previous definition is here}} |
| 34 | switch (int x=0) { default: int x; } // expected-error: {{redefinition of 'x'}} expected-error: {{previous definition is here}} |
| 35 | } |