diff options
author | Richard Guenther <rguenther@suse.de> | 2010-01-31 17:01:38 +0000 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2010-01-31 17:01:38 +0000 |
commit | 61c7cbf8e5502fe6da677581d5c151193049d850 (patch) | |
tree | 4d98e1d16b91ce092b061d30f5405e34bf72230c /gcc/gimplify.c | |
parent | 6e4a660f122aa663077ebc4250597a40904a0720 (diff) | |
download | gcc-61c7cbf8e5502fe6da677581d5c151193049d850.zip gcc-61c7cbf8e5502fe6da677581d5c151193049d850.tar.gz gcc-61c7cbf8e5502fe6da677581d5c151193049d850.tar.bz2 |
re PR middle-end/42898 (volatile structures and compound literal initializers)
2010-01-31 Richard Guenther <rguenther@suse.de>
PR middle-end/42898
* gimplify.c (gimplify_init_constructor): For volatile LHS
initialize a temporary.
* gcc.dg/torture/pr42898.c: New testcase.
From-SVN: r156404
Diffstat (limited to 'gcc/gimplify.c')
-rw-r--r-- | gcc/gimplify.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/gcc/gimplify.c b/gcc/gimplify.c index ccae4d8..fac3fda 100644 --- a/gcc/gimplify.c +++ b/gcc/gimplify.c @@ -3745,6 +3745,21 @@ gimplify_init_constructor (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p, } } + /* If the target is volatile and we have non-zero elements + initialize the target from a temporary. */ + if (TREE_THIS_VOLATILE (object) + && !TREE_ADDRESSABLE (type) + && num_nonzero_elements > 0) + { + tree temp = create_tmp_var (TYPE_MAIN_VARIANT (type), NULL); + TREE_OPERAND (*expr_p, 0) = temp; + *expr_p = build2 (COMPOUND_EXPR, TREE_TYPE (*expr_p), + *expr_p, + build2 (MODIFY_EXPR, void_type_node, + object, temp)); + return GS_OK; + } + if (notify_temp_creation) return GS_OK; |