From: Jakub Jelinek Date: Thu, 1 Apr 2004 16:20:27 +0000 (+0200) Subject: re PR c/14069 (This input file lets gcc crash) X-Git-Tag: releases/gcc-3.3.4~111 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2d1a4ea086f6e03bd466897f7fc088dba5388e5b;p=thirdparty%2Fgcc.git re PR c/14069 (This input file lets gcc crash) PR c/14069 * c-decl.c (finish_struct): Change type of incorrect flexible array field into error_mark_node. Backport from mainline: 2003-04-07 J"orn Rennecke * c-typeck.c (output_init_element): Check for type == error_mark_node. testsuite/ PR c/14069 * gcc.dg/20040322-1.c: New test. Backport from mainline: 2003-04-07 J"orn Rennecke * gcc.dg/noncompile/init-4.c: New test. From-SVN: r80299 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 5f0017c34ac2..6d7b7bbebaf5 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,14 @@ +2004-04-01 Jakub Jelinek + + PR c/14069 + * c-decl.c (finish_struct): Change type of incorrect flexible array + field into error_mark_node. + + Backport from mainline: + 2003-04-07 J"orn Rennecke + + * c-typeck.c (output_init_element): Check for type == error_mark_node. + 2004-04-01 Alan Modra * dwarf2out.c (DEBUG_STR_SECTION_FLAGS): Heed flag_merge_constants. diff --git a/gcc/c-decl.c b/gcc/c-decl.c index 5cb5270084df..543a67480ab7 100644 --- a/gcc/c-decl.c +++ b/gcc/c-decl.c @@ -5320,12 +5320,21 @@ finish_struct (t, fieldlist, attributes) && TYPE_MAX_VALUE (TYPE_DOMAIN (TREE_TYPE (x))) == NULL_TREE) { if (TREE_CODE (t) == UNION_TYPE) - error_with_decl (x, "flexible array member in union"); + { + error_with_decl (x, "flexible array member in union"); + TREE_TYPE (x) = error_mark_node; + } else if (TREE_CHAIN (x) != NULL_TREE) - error_with_decl (x, "flexible array member not at end of struct"); + { + error_with_decl (x, "flexible array member not at end of struct"); + TREE_TYPE (x) = error_mark_node; + } else if (! saw_named_field) - error_with_decl (x, "flexible array member in otherwise empty struct"); - } + { + error_with_decl (x, "flexible array member in otherwise empty struct"); + TREE_TYPE (x) = error_mark_node; + } + } if (pedantic && TREE_CODE (t) == RECORD_TYPE && flexible_array_type_p (TREE_TYPE (x))) diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c index a3d45cc7f18c..12faaa7115c0 100644 --- a/gcc/c-typeck.c +++ b/gcc/c-typeck.c @@ -6241,6 +6241,11 @@ output_init_element (value, type, field, pending) tree value, type, field; int pending; { + if (type == error_mark_node) + { + constructor_erroneous = 1; + return; + } if (TREE_CODE (TREE_TYPE (value)) == FUNCTION_TYPE || (TREE_CODE (TREE_TYPE (value)) == ARRAY_TYPE && !(TREE_CODE (value) == STRING_CST diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index c600736706c9..f3d3cd84eb42 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,13 @@ +2004-03-27 Jakub Jelinek + + PR c/14069 + * gcc.dg/20040322-1.c: New test. + + Backport from mainline: + 2003-04-07 J"orn Rennecke + + * gcc.dg/noncompile/init-4.c: New test. + 2004-03-25 Eric Botcazou * gcc.dg/20040127-1.c: New test.