From: Chris Lattner Date: Wed, 12 Nov 2008 21:25:45 +0000 (+0000) Subject: Fix a FIXME by improving a diagnostic, add a testcase for PR3048 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=67027a7bc35671bc3f6d5c109720060f06303391;p=clang 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 451e8de630..9073e26c98 100644 --- a/include/clang/Basic/DiagnosticKinds.def +++ b/include/clang/Basic/DiagnosticKinds.def @@ -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, diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 1a85bf4686..bf29bdf2ce 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -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; } diff --git a/test/Sema/vla.c b/test/Sema/vla.c index 5f4857e310..682d2fb266 100644 --- a/test/Sema/vla.c +++ b/test/Sema/vla.c @@ -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}} +