2007-10-11 08:18:28 +08:00
// RUN: clang %s -fsyntax-only -verify -pedantic
2007-08-28 14:15:15 +08:00
enum e { A ,
B = 42LL < < 32 , // expected-warning {{ISO C restricts enumerator values to range of 'int'}}
C = - 4 , D = 12456 } ;
enum f { a = - 2147483648 , b = 2147483647 } ; // ok.
enum g { // too negative
c = - 2147483649 , // expected-warning {{ISO C restricts enumerator values to range of 'int'}}
d = 2147483647 } ;
enum h { e = - 2147483648 , // too pos
f = 2147483648 // expected-warning {{ISO C restricts enumerator values to range of 'int'}}
} ;
// minll maxull
enum x // expected-warning {{enumeration values exceed range of largest integer}}
{ y = - 9223372036854775807LL - 1 , // expected-warning {{ISO C restricts enumerator values to range of 'int'}}
z = 9223372036854775808ULL } ; // expected-warning {{ISO C restricts enumerator values to range of 'int'}}
int test ( ) {
return sizeof ( enum e ) ;
}
2008-01-18 08:39:39 +08:00
enum gccForwardEnumExtension ve ; // expected-error {{variable has incomplete type 'enum gccForwardEnumExtension'}} expected-warning{{ISO C forbids forward references to 'enum' types}}
2008-01-17 07:54:22 +08:00
int test2 ( int i )
{
2008-01-18 08:39:39 +08:00
ve + i ;
2008-01-17 07:54:22 +08:00
}
2008-07-03 11:30:58 +08:00
// PR2020
2008-11-24 07:12:31 +08:00
union u0 ; // expected-note {{previous use is here}}
enum u0 { U0A } ; // expected-error {{use of 'u0' with tag type that does not match previous declaration}}
2008-07-03 11:30:58 +08:00
2008-07-26 07:18:17 +08:00
// rdar://6095136
extern enum some_undefined_enum ve2 ; // expected-warning {{ISO C forbids forward references to 'enum' types}}
void test4 ( ) {
for ( ; ve2 ; ) // expected-error {{statement requires expression of scalar type}}
;
2008-07-26 07:41:08 +08:00
( _Bool ) ve2 ; // expected-error {{arithmetic or pointer type is required}}
2008-07-26 07:18:17 +08:00
for ( ; ; ve2 )
;
( void ) ve2 ;
2008-07-26 07:41:08 +08:00
ve2 ; // expected-warning {{expression result unused}}
2008-07-26 07:18:17 +08:00
}
2008-07-27 03:15:11 +08:00
// PR2416
enum someenum { } ; // expected-warning {{use of empty enum extension}}
2008-08-08 00:22:45 +08:00
// <rdar://problem/6093889>
2008-11-24 07:12:31 +08:00
enum e0 { // expected-note {{previous definition is here}}
2008-08-08 00:22:45 +08:00
E0 = sizeof ( enum e0 { E1 } ) // expected-error {{nested redefinition}}
} ;