2009-12-15 20:14:24 +00:00
// RUN: %clang_cc1 %s -verify -fsyntax-only -pedantic
2007-12-18 07:15:40 +00:00
int test1 ( ) {
typedef int x [ test1 ( ) ] ; // vla
2008-08-10 01:58:45 +00:00
static int y = sizeof ( x ) ; // expected-error {{not a compile-time constant}}
2007-12-18 07:15:40 +00:00
}
2008-05-21 05:06:46 +00:00
// PR2347
void f ( unsigned int m )
{
2008-05-21 05:37:55 +00:00
int e [ 2 ] [ m ] ;
2008-05-21 05:06:46 +00:00
e [ 0 ] [ 0 ] = 0 ;
}
2008-11-12 21:25:45 +00:00
// PR3048
2008-11-24 01:28:17 +00:00
int x = sizeof ( struct { char qq [ x ] ; } ) ; // expected-error {{fields must have a constant size}}
2008-11-12 21:25:45 +00:00
2008-12-07 00:20:55 +00:00
// PR2352
void f2 ( unsigned int m )
{
2009-02-24 19:23:27 +00:00
extern int e1 [ 2 ] [ m ] ; // expected-error {{variable length array declaration can not have 'extern' linkage}}
2008-12-07 00:20:55 +00:00
2009-02-24 19:23:27 +00:00
e1 [ 0 ] [ 0 ] = 0 ;
2008-12-07 00:20:55 +00:00
}
// PR2361
int i ;
2008-12-07 00:59:53 +00:00
int c [ ] [ i ] ; // expected-error {{variably modified type declaration not allowed at file scope}}
int d [ i ] ; // expected-error {{variable length array declaration not allowed at file scope}}
2008-12-07 00:20:55 +00:00
2008-12-07 00:59:53 +00:00
int ( * e ) [ i ] ; // expected-error {{variably modified type declaration not allowed at file scope}}
2008-12-07 00:20:55 +00:00
void f3 ( )
{
static int a [ i ] ; // expected-error {{variable length array declaration can not have 'static' storage duration}}
extern int b [ i ] ; // expected-error {{variable length array declaration can not have 'extern' linkage}}
2009-02-24 19:23:27 +00:00
extern int ( * c1 ) [ i ] ; // expected-error {{variably modified type declaration can not have 'extern' linkage}}
2008-12-07 00:20:55 +00:00
static int ( * d ) [ i ] ;
}
2009-02-26 03:58:54 +00:00
// PR3663
2011-06-14 06:38:10 +00:00
static const unsigned array [ ( ( 2 * ( int ) ( ( ( ( 4 ) / 2 ) + 1.0 / 3.0 ) * ( 4 ) - 1e-8 ) ) + 1 ) ] ; // expected-warning {{variable length array folded to constant array as an extension}}
2009-04-26 21:57:51 +00:00
int a [ * ] ; // expected-error {{star modifier used outside of function prototype}}
int f4 ( int a [ * ] [ * ] ) ;
2009-05-16 12:15:55 +00:00
// PR2044
int pr2044 ( int b ) { int ( * c ( void ) ) [ b ] ; * * c ( ) = 2 ; } // expected-error {{variably modified type}}
int pr2044b ;
int ( * pr2044c ( void ) ) [ pr2044b ] ; // expected-error {{variably modified type}}
2009-05-29 16:34:15 +00:00
const int f5_ci = 1 ;
2011-06-14 06:38:10 +00:00
void f5 ( ) { char a [ ] [ f5_ci ] = { " " } ; } // expected-warning {{variable length array folded to constant array as an extension}}
2010-02-01 05:02:49 +00:00
// PR5185
void pr5185 ( int a [ * ] ) ;
void pr5185 ( int a [ * ] ) / / expected - error { { variable length array must be bound in function definition } }
{
}