+2005-04-01 Joseph S. Myers <joseph@codesourcery.com>
+
+ PR c/17855
+ * gimplify.c (gimplify_expr): Create a temporary for lvalue
+ COND_EXPR and CALL_EXPR.
+
2005-03-31 Vladimir Makarov <vmakarov@redhat.com>
PR target/20632
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:
+2005-04-01 Joseph S. Myers <joseph@codesourcery.com>
+
+ PR c/17855
+ * 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.
+
2005-03-31 Janis Johnson <janis187@us.ibm.com>
* gcc.dg/tls/tls.exp: Remove temporary file.
--- /dev/null
+/* Bug c/17855, using conditional expression for non-lvalue. */
+struct foo {char x, y, z[2];};
+struct foo p, q; int r;
+void bar(int baz)
+{
+ (r ? p : q).z[baz] = 1;
+}