From a454baad4ad69b2a27375b5b53d531bc1eb47604 Mon Sep 17 00:00:00 2001 From: hainque Date: Wed, 14 Sep 2005 06:59:10 +0000 Subject: [PATCH] * gimplify.c (gimplify_init_ctor_eval): Don't discard a zero-sized value if it has side-effects. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@104262 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 5 +++++ gcc/gimplify.c | 7 ++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index d4944d5..a0da848 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2005-09-14 Olivier Hainque + + * gimplify.c (gimplify_init_ctor_eval): Don't discard a zero-sized + value if it has side-effects. + 2005-09-14 David Edelsohn PR target/22068 diff --git a/gcc/gimplify.c b/gcc/gimplify.c index a2fc7c8..cdb8a33 100644 --- a/gcc/gimplify.c +++ b/gcc/gimplify.c @@ -2576,7 +2576,12 @@ gimplify_init_ctor_eval (tree object, VEC(constructor_elt,gc) *elts, so we don't have to figure out what's missing ourselves. */ gcc_assert (purpose); - if (zero_sized_field_decl (purpose)) + /* Skip zero-sized fields, unless value has side-effects. This can + happen with calls to functions returning a zero-sized type, which + we shouldn't discard. As a number of downstream passes don't + expect sets of zero-sized fields, we rely on the gimplification of + the MODIFY_EXPR we make below to drop the assignment statement. */ + if (! TREE_SIDE_EFFECTS (value) && zero_sized_field_decl (purpose)) continue; /* If we have a RANGE_EXPR, we have to build a loop to assign the -- 2.7.4