summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/vla-init-1.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/gcc.dg/vla-init-1.c')
-rw-r--r--gcc/testsuite/gcc.dg/vla-init-1.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/vla-init-1.c b/gcc/testsuite/gcc.dg/vla-init-1.c
new file mode 100644
index 000000000..68e7d6512
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vla-init-1.c
@@ -0,0 +1,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" "" { target *-*-* } 12 } */
+ /* { dg-warning "near initialization" "" { target *-*-* } 12 } */
+}