summaryrefslogtreecommitdiff
path: root/gcc/gimplify.c
diff options
context:
space:
mode:
authorjsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4>2005-03-31 23:34:44 +0000
committerjsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4>2005-03-31 23:34:44 +0000
commit05fb348da54dfe5d665e375d9986b1e0f910b76b (patch)
tree7792b0bdd163e128984c1a5dd6701ff7587ff7e3 /gcc/gimplify.c
parent17d386e4a66078b713967828c9c265c47317f440 (diff)
downloadgcc-05fb348da54dfe5d665e375d9986b1e0f910b76b.tar.gz
PR c/17855
* gimplify.c (gimplify_expr): Create a temporary for lvalue COND_EXPR and CALL_EXPR. testsuite: * gcc.c-torture/compile/struct-non-lval-1.c, gcc.c-torture/compile/struct-non-lval-2.c, gcc.c-torture/compile/struct-non-lval-3.c: New tests. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@97352 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/gimplify.c')
-rw-r--r--gcc/gimplify.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/gcc/gimplify.c b/gcc/gimplify.c
index 9191baea26a..bd15e045a16 100644
--- a/gcc/gimplify.c
+++ b/gcc/gimplify.c
@@ -3810,10 +3810,28 @@ gimplify_expr (tree *expr_p, tree *pre_p, tree *post_p,
case COND_EXPR:
ret = gimplify_cond_expr (expr_p, pre_p, post_p, NULL_TREE,
fallback);
+ /* C99 code may assign to an array in a structure value of a
+ conditional expression, and this has undefined behavior
+ only on execution, so create a temporary if an lvalue is
+ required. */
+ if (fallback == fb_lvalue)
+ {
+ *expr_p = get_initialized_tmp_var (*expr_p, pre_p, post_p);
+ lang_hooks.mark_addressable (*expr_p);
+ }
break;
case CALL_EXPR:
ret = gimplify_call_expr (expr_p, pre_p, fallback != fb_none);
+ /* C99 code may assign to an array in a structure returned
+ from a function, and this has undefined behavior only on
+ execution, so create a temporary if an lvalue is
+ required. */
+ if (fallback == fb_lvalue)
+ {
+ *expr_p = get_initialized_tmp_var (*expr_p, pre_p, post_p);
+ lang_hooks.mark_addressable (*expr_p);
+ }
break;
case TREE_LIST: