Improve VLA diagnostics/sema checking. Fixes PR2361 and PR2352.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60638 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/test/Sema/array-constraint.c b/test/Sema/array-constraint.c
index 8fa216d..7763e79 100644
--- a/test/Sema/array-constraint.c
+++ b/test/Sema/array-constraint.c
@@ -41,7 +41,7 @@
}
static int I;
-typedef int TA[I]; // expected-error {{arrays with static storage duration must have constant integer length}}
+typedef int TA[I]; // expected-error {{variable length array declaration not allowed in file scope}}
void strFunc(char *);
const char staticAry[] = "test";
diff --git a/test/Sema/typedef-variable-type.c b/test/Sema/typedef-variable-type.c
index 4ced926..346117e 100644
--- a/test/Sema/typedef-variable-type.c
+++ b/test/Sema/typedef-variable-type.c
@@ -1,3 +1,3 @@
// RUN: clang %s -verify -fsyntax-only -pedantic
-typedef int (*a)[!.0]; // expected-error{{arrays with static storage duration must have constant integer length}}
+typedef int (*a)[!.0]; // expected-error{{variably modified type declaration not allowed in file scope}}
diff --git a/test/Sema/vla.c b/test/Sema/vla.c
index 682d2fb..bccd5e6 100644
--- a/test/Sema/vla.c
+++ b/test/Sema/vla.c
@@ -16,3 +16,28 @@
// PR3048
int x = sizeof(struct{char qq[x];}); // expected-error {{fields must have a constant size}}
+// PR2352
+void f2(unsigned int m)
+{
+ extern int e[2][m]; // expected-error {{variable length array declaration can not have 'extern' linkage}}
+
+ e[0][0] = 0;
+
+}
+
+// PR2361
+int i;
+int c[][i]; // expected-error {{variably modified type declaration not allowed in file scope}}
+int d[i]; // expected-error {{variable length array declaration not allowed in file scope}}
+
+int (*e)[i]; // expected-error {{variably modified type declaration not allowed in file scope}}
+
+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}}
+
+ extern int (*c)[i]; // expected-error {{variably modified type declaration can not have 'extern' linkage}}
+ static int (*d)[i];
+}
+