Commit e057e0cd by Andrew Pinski Committed by Andrew Pinski

re PR middle-end/32813 (ICE for array expression in empty if statement, compiled…

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
parent b49957dd
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> 2007-08-09 Daniel Berlin <dberlin@dberlin.org>
* c-typeck.c (readonly_error): Improve error for assignment. * c-typeck.c (readonly_error): Improve error for assignment.
......
...@@ -3537,6 +3537,11 @@ omit_one_operand (tree type, tree result, tree omitted) ...@@ -3537,6 +3537,11 @@ omit_one_operand (tree type, tree result, tree omitted)
{ {
tree t = fold_convert (type, result); 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)) if (TREE_SIDE_EFFECTS (omitted))
return build2 (COMPOUND_EXPR, type, fold_ignored_result (omitted), t); return build2 (COMPOUND_EXPR, type, fold_ignored_result (omitted), t);
...@@ -3550,6 +3555,11 @@ pedantic_omit_one_operand (tree type, tree result, tree omitted) ...@@ -3550,6 +3555,11 @@ pedantic_omit_one_operand (tree type, tree result, tree omitted)
{ {
tree t = fold_convert (type, result); 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)) if (TREE_SIDE_EFFECTS (omitted))
return build2 (COMPOUND_EXPR, type, fold_ignored_result (omitted), t); return build2 (COMPOUND_EXPR, type, fold_ignored_result (omitted), t);
......
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> 2007-08-08 Richard Sandiford <richard@codesourcery.com>
* gcc.target/mips/code-readable-1.c: New test. * gcc.target/mips/code-readable-1.c: New test.
program emptyif
implicit none
integer i,K(4)
if (K(i)==0) then
! do absolutely nothing
end if
end program
...@@ -347,6 +347,7 @@ proc search_for_re { file pattern } { ...@@ -347,6 +347,7 @@ proc search_for_re { file pattern } {
proc fortran-torture { args } { proc fortran-torture { args } {
global srcdir subdir global srcdir subdir
global compiler_conditional_xfail_data global compiler_conditional_xfail_data
global TORTURE_OPTIONS
set src [lindex $args 0] set src [lindex $args 0]
if { [llength $args] > 1 } { if { [llength $args] > 1 } {
...@@ -371,7 +372,7 @@ proc fortran-torture { args } { ...@@ -371,7 +372,7 @@ proc fortran-torture { args } {
} }
# loop through all the options # loop through all the options
set option_list [list { "-O" } ] set option_list $TORTURE_OPTIONS
foreach option $option_list { foreach option $option_list {
# torture_compile_xfail is set by the .x script (if present) # torture_compile_xfail is set by the .x script (if present)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment