summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/vla-init-1.c
blob: 38e9b011b9c1fdb65077b8c8b7d7bae881f7b032 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
/* Test for tree-checking error when initializing a variable-length array
   (not allowed): constructor_max_index needs to be an INTEGER_CST.  */
/* Origin: Joseph Myers <jsm28@cam.ac.uk>.  */
/* { dg-do compile } */
/* { dg-options "" } */

int a;

void
foo (void)
{
  int x[a] = { 1 }; /* { dg-error "variable-sized object may not be initialized" "VLA init" } */
  /* { dg-warning "excess elements in array initializer" "excess" { target *-*-* } .-1 } */
  /* { dg-message "near initialization" "near" { target *-*-* } .-2 } */
}