[cfe-commits] r59167 - in /cfe/trunk: include/clang/Basic/DiagnosticKinds.def lib/Sema/SemaDecl.cpp test/Sema/vla.c

Chris Lattner sabre at nondot.org
Wed Nov 12 13:26:01 PST 2008


Author: lattner
Date: Wed Nov 12 15:25:45 2008
New Revision: 59167

URL: http://llvm.org/viewvc/llvm-project?rev=59167&view=rev
Log:
Fix a FIXME by improving a diagnostic, add a testcase for PR3048


Modified:
    cfe/trunk/include/clang/Basic/DiagnosticKinds.def
    cfe/trunk/lib/Sema/SemaDecl.cpp
    cfe/trunk/test/Sema/vla.c

Modified: cfe/trunk/include/clang/Basic/DiagnosticKinds.def
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticKinds.def?rev=59167&r1=59166&r2=59167&view=diff

==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticKinds.def (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticKinds.def Wed Nov 12 15:25:45 2008
@@ -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,

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=59167&r1=59166&r2=59167&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Wed Nov 12 15:25:45 2008
@@ -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;
     }

Modified: cfe/trunk/test/Sema/vla.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/vla.c?rev=59167&r1=59166&r2=59167&view=diff

==============================================================================
--- cfe/trunk/test/Sema/vla.c (original)
+++ cfe/trunk/test/Sema/vla.c Wed Nov 12 15:25:45 2008
@@ -13,3 +13,6 @@
   e[0][0] = 0;
 }
 
+// PR3048
+int x = sizeof(struct{char qq[x];}); // expected-error {{fields must have a constant size}}
+





More information about the cfe-commits mailing list