aboutsummaryrefslogtreecommitdiff
path: root/gcc/expr.c
diff options
context:
space:
mode:
authorJ"orn Rennecke <amylaar@cygnus.co.uk>1999-10-14 02:18:10 +0000
committerJoern Rennecke <amylaar@gcc.gnu.org>1999-10-14 03:18:10 +0100
commita59f86402f8ffb904e9dccb10568371a890e1f30 (patch)
tree4156840afb1607ce49dc0ece52f2b961fbaa942f /gcc/expr.c
parent5cf531a862a201c899afabde00e1cdc8b04cd9c9 (diff)
downloadgcc-a59f86402f8ffb904e9dccb10568371a890e1f30.zip
gcc-a59f86402f8ffb904e9dccb10568371a890e1f30.tar.gz
gcc-a59f86402f8ffb904e9dccb10568371a890e1f30.tar.bz2
gcc toplevel:
* expr.c (store_constructor): Clear union if constructor is empty. cp: * typeck2.c (process_init_constructor): Handle empty constructors. testsuite: * g++.old-deja/g++.other/union2.C: New test. From-SVN: r29956
Diffstat (limited to 'gcc/expr.c')
-rw-r--r--gcc/expr.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/gcc/expr.c b/gcc/expr.c
index 79e651f..e246020 100644
--- a/gcc/expr.c
+++ b/gcc/expr.c
@@ -4073,7 +4073,14 @@ store_constructor (exp, target, align, cleared)
/* Inform later passes that the whole union value is dead. */
if (TREE_CODE (type) == UNION_TYPE
|| TREE_CODE (type) == QUAL_UNION_TYPE)
- emit_insn (gen_rtx_CLOBBER (VOIDmode, target));
+ {
+ emit_insn (gen_rtx_CLOBBER (VOIDmode, target));
+
+ /* If the constructor is empty, clear the union. */
+ if (! CONSTRUCTOR_ELTS (exp) && ! cleared)
+ clear_storage (target, expr_size (exp),
+ TYPE_ALIGN (type) / BITS_PER_UNIT);
+ }
/* If we are building a static constructor into a register,
set the initial value as zero so we can fold the value into