2009-12-15 23:14:24 +03:00
// RUN: %clang_cc1 -fsyntax-only -verify %s
2008-09-10 06:17:11 +04:00
void test ( ) {
2008-09-11 03:34:50 +04:00
int x ;
if ( x ) + + x ;
2008-09-10 06:17:11 +04:00
if ( int x = 0 ) + + x ;
typedef int arr [ 10 ] ;
2009-12-19 11:11:05 +03:00
while ( arr x = 0 ) ; // expected-error {{an array type is not allowed here}} expected-error {{array initializer must be an initializer list}}
2008-11-24 02:12:31 +03:00
while ( int f ( ) = 0 ) ; // expected-error {{a function type is not allowed here}}
2008-09-10 06:17:11 +04:00
struct S { } s ;
2009-01-14 18:45:31 +03:00
if ( s ) + + x ; // expected-error {{value of type 'struct S' is not contextually convertible to 'bool'}}
while ( struct S x = s ) ; // expected-error {{value of type 'struct S' is not contextually convertible to 'bool'}}
do ; while ( s ) ; // expected-error {{value of type 'struct S' is not contextually convertible to 'bool'}}
for ( ; s ; ) ; // expected-error {{value of type 'struct S' is not contextually convertible to 'bool'}}
2008-11-24 02:12:31 +03:00
switch ( s ) { } // expected-error {{statement requires expression of integer type ('struct S' invalid)}}
2008-09-10 06:17:11 +04:00
2010-01-13 03:25:19 +03:00
while ( struct S { } x = 0 ) ; // expected-error {{types may not be defined in conditions}} expected-error {{no viable conversion}} expected-error {{value of type 'struct S' is not contextually convertible to 'bool'}} expected-note{{candidate constructor (the implicit copy constructor)}}
2010-03-19 10:56:44 +03:00
while ( struct { } x = 0 ) ; // expected-error {{types may not be defined in conditions}} expected-error {{no viable conversion}} expected-error {{not contextually convertible to 'bool'}} expected-note{{candidate constructor (the implicit copy constructor)}}
2010-02-18 02:29:11 +03:00
switch ( enum { E } x = 0 ) ; / / expected - error { { types may not be defined in conditions } } expected - error { { cannot initialize } } \
// expected-warning{{enumeration value 'E' not handled in switch}}
2008-09-10 06:17:11 +04:00
2009-02-07 22:52:04 +03:00
if ( int x = 0 ) { // expected-note 2 {{previous definition is here}}
2008-11-24 02:12:31 +03:00
int x ; // expected-error {{redefinition of 'x'}}
2008-09-10 06:17:11 +04:00
}
else
2008-11-24 02:12:31 +03:00
int x ; // expected-error {{redefinition of 'x'}}
while ( int x = 0 ) int x ; // expected-error {{redefinition of 'x'}} expected-note {{previous definition is here}}
while ( int x = 0 ) { int x ; } // expected-error {{redefinition of 'x'}} expected-note {{previous definition is here}}
for ( int x ; int x = 0 ; ) ; // expected-error {{redefinition of 'x'}} expected-note {{previous definition is here}}
for ( int x ; ; ) int x ; // expected-error {{redefinition of 'x'}} expected-note {{previous definition is here}}
for ( ; int x = 0 ; ) int x ; // expected-error {{redefinition of 'x'}} expected-note {{previous definition is here}}
for ( ; int x = 0 ; ) { int x ; } // expected-error {{redefinition of 'x'}} expected-note {{previous definition is here}}
switch ( int x = 0 ) { default : int x ; } // expected-error {{redefinition of 'x'}} expected-note {{previous definition is here}}
2008-09-10 06:17:11 +04:00
}
2009-11-25 03:27:52 +03:00
int * get_int_ptr ( ) ;
void test2 ( ) {
float * ip ;
if ( int * ip = ip ) {
}
}
2010-12-04 09:09:13 +03:00
// Make sure we do function/array decay.
void test3 ( ) {
if ( " help " )
( void ) 0 ;
if ( test3 )
( void ) 0 ;
}