Fix a FIXME by improving a diagnostic, add a testcase for PR3048
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59167 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/clang/Basic/DiagnosticKinds.def b/include/clang/Basic/DiagnosticKinds.def
index 451e8de..9073e26 100644
--- a/include/clang/Basic/DiagnosticKinds.def
+++ b/include/clang/Basic/DiagnosticKinds.def
@@ -922,6 +922,8 @@
"size of static array must be an integer constant expression")
DIAG(err_typecheck_illegal_vla, ERROR,
"arrays with static storage duration must have constant integer length")
+DIAG(err_typecheck_field_variable_size, ERROR,
+ "fields must have a constant size")
DIAG(err_typecheck_negative_array_size, ERROR,
"array size is negative")
DIAG(warn_typecheck_function_qualifiers, WARNING,
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index 1a85bf4..bf29bdf 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/lib/Sema/SemaDecl.cpp
@@ -2541,8 +2541,7 @@
Diag(Loc, diag::warn_illegal_constant_array_size, Loc);
T = FixedTy;
} else {
- // FIXME: This diagnostic needs work
- Diag(Loc, diag::err_typecheck_illegal_vla, Loc);
+ Diag(Loc, diag::err_typecheck_field_variable_size, Loc);
T = Context.IntTy;
InvalidDecl = true;
}
diff --git a/test/Sema/vla.c b/test/Sema/vla.c
index 5f4857e..682d2fb 100644
--- a/test/Sema/vla.c
+++ b/test/Sema/vla.c
@@ -13,3 +13,6 @@
e[0][0] = 0;
}
+// PR3048
+int x = sizeof(struct{char qq[x];}); // expected-error {{fields must have a constant size}}
+