]> granicus.if.org Git - clang/commitdiff
Fix a FIXME by improving a diagnostic, add a testcase for PR3048
authorChris Lattner <sabre@nondot.org>
Wed, 12 Nov 2008 21:25:45 +0000 (21:25 +0000)
committerChris Lattner <sabre@nondot.org>
Wed, 12 Nov 2008 21:25:45 +0000 (21:25 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59167 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/DiagnosticKinds.def
lib/Sema/SemaDecl.cpp
test/Sema/vla.c

index 451e8de630b955c41c5bff8848f45adc868299c4..9073e26c98f26efb19382f27883df685907d574d 100644 (file)
@@ -922,6 +922,8 @@ DIAG(warn_illegal_constant_array_size, EXTENSION,
      "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,
index 1a85bf46868c8180de3fd079ea2522931d9015a2..bf29bdf2cee0f5f8300f06c044ca10bfa92c2e05 100644 (file)
@@ -2541,8 +2541,7 @@ Sema::DeclTy *Sema::ActOnField(Scope *S,
       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;
     }
index 5f4857e3101686b9ee0a496dd3d8da2ccd16b4df..682d2fb2667fdff96b08d21a577bf916a53d7bf8 100644 (file)
@@ -13,3 +13,6 @@ void f (unsigned int m)
   e[0][0] = 0;
 }
 
+// PR3048
+int x = sizeof(struct{char qq[x];}); // expected-error {{fields must have a constant size}}
+