From 2194bb78ecf4d260d5a4e5b73420fe86c0c10607 Mon Sep 17 00:00:00 2001 From: Eli Friedman Date: Sun, 22 Feb 2009 00:20:44 +0000 Subject: [PATCH] Sanity fix for PR3642: if we're treating a diagnostic as an error, it's required to actually be an error for correctness. The attached testcase now gives an error instead of mysteriously crashing. Now, it's possible we actually want to support the given usage, but I haven't looked at the relevant code closely. llvm-svn: 65253 --- clang/include/clang/Basic/DiagnosticSemaKinds.def | 2 +- clang/test/Sema/struct-decl.c | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.def b/clang/include/clang/Basic/DiagnosticSemaKinds.def index 7ebb5a706cda..fb9f36399baf 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.def +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.def @@ -728,7 +728,7 @@ DIAG(err_field_declared_as_function, ERROR, "field %0 declared as a function") DIAG(err_field_incomplete, ERROR, "field has incomplete type %0") -DIAG(err_variable_sized_type_in_struct, EXTENSION, +DIAG(err_variable_sized_type_in_struct, ERROR, "variable sized type %0 must be at end of struct or class") DIAG(err_flexible_array_empty_struct, ERROR, "flexible array %0 not allowed in otherwise empty struct") diff --git a/clang/test/Sema/struct-decl.c b/clang/test/Sema/struct-decl.c index cdc9eaae3bbd..aa2d3b6342b6 100644 --- a/clang/test/Sema/struct-decl.c +++ b/clang/test/Sema/struct-decl.c @@ -22,3 +22,14 @@ int foo() { struct st *f; return f->v + f[0].v; } + +// PR3642 +struct pppoe_tag { + short tag_type; + char tag_data[]; +}; +struct datatag { + struct pppoe_tag hdr; //expected-error{{variable sized type 'hdr' must be at end of struct}} + char data; +}; + -- GitLab