From f5a1f0d01fa875ef6f2d895f990f4a2064b9d7f4 Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Mon, 11 May 2009 16:05:45 +0000 Subject: [PATCH] re PR middle-end/40026 (ICE during gimplify_init_constructor) 2009-05-11 Paolo Bonzini PR tree-optimization/40026 * gimplify.c (gimplify_init_constructor): Change initial conditional to assertion. Rewrite TREE_OPERAND (*expr_p, 1) after optimize_compound_literals_in_ctor. testsuite: 2009-05-11 Paolo Bonzini * gcc.c-torture/compile/pr40026.c: New testcase. From-SVN: r147386 --- gcc/ChangeLog | 7 +++++++ gcc/gimplify.c | 13 ++++++------- gcc/testsuite/ChangeLog | 4 ++++ gcc/testsuite/gcc.c-torture/compile/pr40026.c | 15 +++++++++++++++ 4 files changed, 32 insertions(+), 7 deletions(-) create mode 100644 gcc/testsuite/gcc.c-torture/compile/pr40026.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index c07ab68e20e..d50fee47db9 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2009-05-11 Paolo Bonzini + + PR tree-optimization/40026 + * gimplify.c (gimplify_init_constructor): Change initial conditional + to assertion. Rewrite TREE_OPERAND (*expr_p, 1) after + optimize_compound_literals_in_ctor. + 2009-05-11 Nathan Sidwell * config/m68k/m68k-devices.def (52274, 52277, 5301x, 5225x, 51xx): diff --git a/gcc/gimplify.c b/gcc/gimplify.c index 0c33dab479a..bff7cdd4b6f 100644 --- a/gcc/gimplify.c +++ b/gcc/gimplify.c @@ -3643,14 +3643,11 @@ static enum gimplify_status gimplify_init_constructor (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p, bool want_value, bool notify_temp_creation) { - tree object, new_ctor; - tree ctor = TREE_OPERAND (*expr_p, 1); - tree type = TREE_TYPE (ctor); + tree object, ctor, type; enum gimplify_status ret; VEC(constructor_elt,gc) *elts; - if (TREE_CODE (ctor) != CONSTRUCTOR) - return GS_UNHANDLED; + gcc_assert (TREE_CODE (TREE_OPERAND (*expr_p, 1)) == CONSTRUCTOR); if (!notify_temp_creation) { @@ -3661,8 +3658,10 @@ gimplify_init_constructor (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p, } object = TREE_OPERAND (*expr_p, 0); - new_ctor = optimize_compound_literals_in_ctor (ctor); - elts = CONSTRUCTOR_ELTS (new_ctor); + ctor = TREE_OPERAND (*expr_p, 1) = + optimize_compound_literals_in_ctor (TREE_OPERAND (*expr_p, 1)); + type = TREE_TYPE (ctor); + elts = CONSTRUCTOR_ELTS (ctor); ret = GS_ALL_DONE; switch (TREE_CODE (type)) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index f8365a0f95d..bb823365745 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2009-05-11 Paolo Bonzini + + * gcc.c-torture/compile/pr40026.c: New testcase. + 2009-05-11 Janus Weil PR fortran/40089 diff --git a/gcc/testsuite/gcc.c-torture/compile/pr40026.c b/gcc/testsuite/gcc.c-torture/compile/pr40026.c new file mode 100644 index 00000000000..0d08f0dc8ac --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr40026.c @@ -0,0 +1,15 @@ +typedef struct { + unsigned long bits; +} S; +struct T { + S span; + int flags; +}; + +struct T f(int x) +{ + return (struct T) { + .span = (S) { 0UL }, + .flags = (x ? 256 : 0), + }; +}