2008-09-10 10:17:11 +08:00
// RUN: clang -fsyntax-only -verify %s
void test ( ) {
2008-09-11 07:34:50 +08:00
int x ;
if ( x ) + + x ;
2008-09-10 10:17:11 +08:00
if ( int x = 0 ) + + x ;
typedef int arr [ 10 ] ;
2008-11-23 06:39:41 +08:00
while ( arr x = 0 ) ; // expected-error: {{an array type is not allowed here}} expected-error: {{initialization with '{...}' expected for array}}
2008-09-10 10:17:11 +08:00
while ( int f ( ) = 0 ) ; // expected-error: {{a function type is not allowed here}}
struct S { } s ;
2008-09-11 07:34:50 +08:00
if ( s ) + + x ; // expected-error: {{expression must have bool type (or be convertible to bool) ('struct S' invalid)}}
2008-09-10 10:17:11 +08:00
while ( struct S x = s ) ; // expected-error: {{expression must have bool type (or be convertible to bool) ('struct S' invalid)}}
2008-09-11 13:16:22 +08:00
do ; while ( s ) ; // expected-error: {{expression must have bool type (or be convertible to bool) ('struct S' invalid)}}
for ( ; s ; ) ; // expected-error: {{expression must have bool type (or be convertible to bool) ('struct S' invalid)}}
2008-09-10 10:17:11 +08:00
switch ( s ) { } // expected-error: {{statement requires expression of integer type ('struct S' invalid)}}
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}}
while ( struct { } x = 0 ) ; // expected-error: {{types may not be defined in conditions}} expected-error: {{incompatible type}} expected-error: {{expression must have bool type}}
2008-10-31 22:43:28 +08:00
switch ( enum { E } x = 0 ) ; // expected-error: {{types may not be defined in conditions}} expected-error: {{incompatible type}}
2008-09-10 10:17:11 +08:00
if ( int x = 0 ) { // expected-error: {{previous definition is here}}
int x ; // expected-error: {{redefinition of 'x'}}
}
else
int x ; // expected-error: {{redefinition of 'x'}}
while ( int x = 0 ) int x ; // expected-error: {{redefinition of 'x'}} expected-error: {{previous definition is here}}
while ( int x = 0 ) { int x ; } // expected-error: {{redefinition of 'x'}} expected-error: {{previous definition is here}}
for ( int x ; int x = 0 ; ) ; // expected-error: {{redefinition of 'x'}} expected-error: {{previous definition is here}}
for ( int x ; ; ) int x ; // expected-error: {{redefinition of 'x'}} expected-error: {{previous definition is here}}
for ( ; int x = 0 ; ) int x ; // expected-error: {{redefinition of 'x'}} expected-error: {{previous definition is here}}
for ( ; int x = 0 ; ) { int x ; } // expected-error: {{redefinition of 'x'}} expected-error: {{previous definition is here}}
switch ( int x = 0 ) { default : int x ; } // expected-error: {{redefinition of 'x'}} expected-error: {{previous definition is here}}
}