From 6f8f67e97de542d658c759ab1e55d8b7cfed4f58 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Fri, 24 Aug 2012 23:46:17 +0200 Subject: re PR c/54363 (ICE when compiling malformed struct initializers) PR c/54363 * gimplify.c (optimize_compound_literals_in_ctor): Only recurse if init is a CONSTRUCTOR. * gcc.dg/pr54363.c: New test. From-SVN: r190657 --- gcc/ChangeLog | 6 ++++++ gcc/gimplify.c | 3 ++- gcc/testsuite/ChangeLog | 3 +++ gcc/testsuite/gcc.dg/pr54363.c | 12 ++++++++++++ 4 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.dg/pr54363.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index a51eea2..f160b8f 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2012-08-24 Jakub Jelinek + + PR c/54363 + * gimplify.c (optimize_compound_literals_in_ctor): Only recurse + if init is a CONSTRUCTOR. + 2012-08-24 Steven Bosscher * tree-ssa-live.c (dump_var_map): Do not dump the partition diff --git a/gcc/gimplify.c b/gcc/gimplify.c index ed2474f..2793027 100644 --- a/gcc/gimplify.c +++ b/gcc/gimplify.c @@ -3857,7 +3857,8 @@ optimize_compound_literals_in_ctor (tree orig_ctor) if (!TREE_ADDRESSABLE (value) && !TREE_ADDRESSABLE (decl) - && init) + && init + && TREE_CODE (init) == CONSTRUCTOR) newval = optimize_compound_literals_in_ctor (init); } if (newval == value) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 6fa0755..eeb62dc 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2012-08-24 Jakub Jelinek + PR c/54363 + * gcc.dg/pr54363.c: New test. + PR c/54355 * gcc.dg/pr54355.c: New test. diff --git a/gcc/testsuite/gcc.dg/pr54363.c b/gcc/testsuite/gcc.dg/pr54363.c new file mode 100644 index 0000000..aea0f905 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr54363.c @@ -0,0 +1,12 @@ +/* PR c/54363 */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu99" } */ + +struct S { char **a; }; + +void +test (void) +{ + struct S b = { .a = (char **) { "a", "b" } }; /* { dg-warning "(initialization|excess elements)" } */ + struct S c = { .a = (char *[]) { "a", "b" } }; +} -- cgit v1.1