diff options
author | Andrew Pinski <andrew_pinski@playstation.sony.com> | 2007-08-09 21:36:27 +0000 |
---|---|---|
committer | Andrew Pinski <pinskia@gcc.gnu.org> | 2007-08-09 14:36:27 -0700 |
commit | e057e0cd1d9141a4251756d1830cc0939494208c (patch) | |
tree | f030259702f6f708be9e2015d13e0c09eda84183 | |
parent | b49957dd09afec707bfa70a68eb32c6e976befc1 (diff) | |
download | gcc-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
-rw-r--r-- | gcc/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/fold-const.c | 10 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/testsuite/gfortran.fortran-torture/compile/emptyif-1.f90 | 10 | ||||
-rw-r--r-- | gcc/testsuite/lib/fortran-torture.exp | 3 |
5 files changed, 36 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index f9cfb2e..410cf54 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +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 Daniel Berlin <dberlin@dberlin.org> * c-typeck.c (readonly_error): Improve error for assignment. 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); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 5dd66c3..06b2fff 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,10 @@ +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. + 2007-08-08 Richard Sandiford <richard@codesourcery.com> * gcc.target/mips/code-readable-1.c: New test. diff --git a/gcc/testsuite/gfortran.fortran-torture/compile/emptyif-1.f90 b/gcc/testsuite/gfortran.fortran-torture/compile/emptyif-1.f90 new file mode 100644 index 0000000..bdce67d --- /dev/null +++ b/gcc/testsuite/gfortran.fortran-torture/compile/emptyif-1.f90 @@ -0,0 +1,10 @@ +program emptyif + + implicit none + integer i,K(4) + + if (K(i)==0) then + ! do absolutely nothing + end if + +end program diff --git a/gcc/testsuite/lib/fortran-torture.exp b/gcc/testsuite/lib/fortran-torture.exp index 8bc5978..d97c2ce 100644 --- a/gcc/testsuite/lib/fortran-torture.exp +++ b/gcc/testsuite/lib/fortran-torture.exp @@ -347,6 +347,7 @@ proc search_for_re { file pattern } { proc fortran-torture { args } { global srcdir subdir global compiler_conditional_xfail_data + global TORTURE_OPTIONS set src [lindex $args 0] if { [llength $args] > 1 } { @@ -371,7 +372,7 @@ proc fortran-torture { args } { } # loop through all the options - set option_list [list { "-O" } ] + set option_list $TORTURE_OPTIONS foreach option $option_list { # torture_compile_xfail is set by the .x script (if present) |