aboutsummaryrefslogtreecommitdiff
path: root/gcc/fold-const.c
diff options
context:
space:
mode:
authorAndrew Pinski <andrew_pinski@playstation.sony.com>2007-08-09 21:36:27 +0000
committerAndrew Pinski <pinskia@gcc.gnu.org>2007-08-09 14:36:27 -0700
commite057e0cd1d9141a4251756d1830cc0939494208c (patch)
treef030259702f6f708be9e2015d13e0c09eda84183 /gcc/fold-const.c
parentb49957dd09afec707bfa70a68eb32c6e976befc1 (diff)
downloadgcc-e057e0cd1d9141a4251756d1830cc0939494208c.zip
gcc-e057e0cd1d9141a4251756d1830cc0939494208c.tar.gz
gcc-e057e0cd1d9141a4251756d1830cc0939494208c.tar.bz2
re PR middle-end/32813 (ICE for array expression in empty if statement, compiled with -fbounds-check)
2007-08-09 Andrew Pinski <andrew_pinski@playstation.sony.com> PR middle-end/32813 * fold-const.c (omit_one_operand): Return only the ommitted expression if the result is an empty statement. (pedantic_omit_one_operand): Likewise. 2007-08-09 Andrew Pinski <andrew_pinski@playstation.sony.com> PR middle-end/32813 * gfortran.fortran-torture/compile/emptyif-1.f90: New test. * lib/fortran-torture.exp (fortran-torture): Use TORTURE_OPTIONS instead of just -O. From-SVN: r127322
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r--gcc/fold-const.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index eadcb97..d5d0f1e 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -3537,6 +3537,11 @@ omit_one_operand (tree type, tree result, tree omitted)
{
tree t = fold_convert (type, result);
+ /* If the resulting operand is an empty statement, just return the ommited
+ statement casted to void. */
+ if (IS_EMPTY_STMT (t) && TREE_SIDE_EFFECTS (omitted))
+ return build1 (NOP_EXPR, void_type_node, fold_ignored_result (omitted));
+
if (TREE_SIDE_EFFECTS (omitted))
return build2 (COMPOUND_EXPR, type, fold_ignored_result (omitted), t);
@@ -3550,6 +3555,11 @@ pedantic_omit_one_operand (tree type, tree result, tree omitted)
{
tree t = fold_convert (type, result);
+ /* If the resulting operand is an empty statement, just return the ommited
+ statement casted to void. */
+ if (IS_EMPTY_STMT (t) && TREE_SIDE_EFFECTS (omitted))
+ return build1 (NOP_EXPR, void_type_node, fold_ignored_result (omitted));
+
if (TREE_SIDE_EFFECTS (omitted))
return build2 (COMPOUND_EXPR, type, fold_ignored_result (omitted), t);