This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Fix PR45750
- From: Richard Guenther <rguenther at suse dot de>
- To: gcc-patches at gcc dot gnu dot org
- Date: Thu, 23 Sep 2010 12:58:44 +0200 (CEST)
- Subject: [PATCH] Fix PR45750
We should propagate GS_ERROR properly.
Bootstrapped and tested on x86_64-unknown-linux-gnu, committed.
Richard.
2010-09-23 Richard Guenther <rguenther@suse.de>
PR middle-end/45750
* gimplify.c (gimplify_expr): Properly pass on GS_ERROR when
gimplifying MEM_REF.
* gcc.dg/pr45750.c: New testcase.
Index: gcc/gimplify.c
===================================================================
*** gcc/gimplify.c (revision 164550)
--- gcc/gimplify.c (working copy)
*************** gimplify_expr (tree *expr_p, gimple_seq
*** 6809,6816 ****
ret = gimplify_expr (&TREE_OPERAND (*expr_p, 0), pre_p, post_p,
is_gimple_reg, fb_rvalue);
! recalculate_side_effects (*expr_p);
*expr_p = fold_build2_loc (input_location, MEM_REF,
TREE_TYPE (*expr_p),
TREE_OPERAND (*expr_p, 0),
--- 6809,6818 ----
ret = gimplify_expr (&TREE_OPERAND (*expr_p, 0), pre_p, post_p,
is_gimple_reg, fb_rvalue);
! if (ret == GS_ERROR)
! break;
+ recalculate_side_effects (*expr_p);
*expr_p = fold_build2_loc (input_location, MEM_REF,
TREE_TYPE (*expr_p),
TREE_OPERAND (*expr_p, 0),
*************** gimplify_expr (tree *expr_p, gimple_seq
*** 6835,6840 ****
--- 6837,6844 ----
}
ret = gimplify_expr (&TREE_OPERAND (*expr_p, 0), pre_p, post_p,
is_gimple_mem_ref_addr, fb_rvalue);
+ if (ret == GS_ERROR)
+ break;
recalculate_side_effects (*expr_p);
ret = GS_ALL_DONE;
break;
Index: gcc/testsuite/gcc.dg/pr45750.c
===================================================================
*** gcc/testsuite/gcc.dg/pr45750.c (revision 0)
--- gcc/testsuite/gcc.dg/pr45750.c (revision 0)
***************
*** 0 ****
--- 1,16 ----
+ /* { dg-do compile } */
+ /* { dg-options "-O" } */
+
+ struct S
+ {
+ int i;
+ };
+
+ int invalid[] = 0; /* { dg-error "invalid initializer" } */
+
+ void foo (void)
+ {
+ if (((struct S *)undeclared)->i); /* { dg-error "undeclared" } */
+ }
+
+ /* { dg-message "reported only once" "" { target *-*-* } 13 } */