+2002-02-06 Jakub Jelinek <jakub@redhat.com>
+
+ PR c/5482:
+ * c-common.c (c_expand_expr) [STMT_EXPR]: If last expression is not
+ EXPR_STMT, but COMPOUND_STMT, recurse into it.
+
2002-02-06 Richard Henderson <rth@redhat.com>
* cfganal.c (keep_with_call_p): Source for fixed_reg dest must
/* If we want the result of this expression, find the last
EXPR_STMT in the COMPOUND_STMT and mark it as addressable. */
- if (target != const0_rtx
- && TREE_CODE (STMT_EXPR_STMT (exp)) == COMPOUND_STMT
- && TREE_CODE (COMPOUND_BODY (STMT_EXPR_STMT (exp))) == SCOPE_STMT)
+ if (target != const0_rtx)
{
- tree expr = COMPOUND_BODY (STMT_EXPR_STMT (exp));
- tree last = TREE_CHAIN (expr);
+ tree expr = STMT_EXPR_STMT (exp);
+ tree last;
- while (TREE_CHAIN (last))
+ while (TREE_CODE (expr) == COMPOUND_STMT
+ && TREE_CODE (COMPOUND_BODY (expr)) == SCOPE_STMT)
{
- expr = last;
- last = TREE_CHAIN (last);
+ expr = COMPOUND_BODY (expr);
+ last = TREE_CHAIN (expr);
+
+ while (TREE_CHAIN (last))
+ {
+ expr = last;
+ last = TREE_CHAIN (last);
+ }
+
+ if (TREE_CODE (last) != SCOPE_STMT)
+ abort ();
+
+ if (TREE_CODE (expr) == EXPR_STMT)
+ {
+ TREE_ADDRESSABLE (expr) = 1;
+ break;
+ }
}
-
- if (TREE_CODE (last) == SCOPE_STMT
- && TREE_CODE (expr) == EXPR_STMT)
- TREE_ADDRESSABLE (expr) = 1;
}
expand_stmt (STMT_EXPR_STMT (exp));
--- /dev/null
+/* This testcase ICEd because c_expand_expr did not mark statement expression
+ return value as one which shouldn't be ignored. */
+
+struct A {
+ unsigned int a, b, c;
+};
+
+extern void abort (void);
+extern void exit (int);
+
+struct A bar (void)
+{
+ return (struct A) { 176, 52, 31 };
+}
+
+void baz (struct A *a)
+{
+ if (a->a != 176 || a->b != 52 || a->c != 31)
+ abort ();
+}
+
+int main ()
+{
+ struct A d;
+
+ d = ({ { bar (); } });
+ baz (&d);
+ exit (0);
+}