From: pinskia Date: Thu, 9 Aug 2007 21:36:27 +0000 (+0000) Subject: 2007-08-09 Andrew Pinski X-Git-Tag: upstream/4.9.2~47042 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9e0e518b2f464fee8828d38d1e56c6a58c4ae3b8;p=platform%2Fupstream%2Flinaro-gcc.git 2007-08-09 Andrew Pinski 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 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@127322 138bc75d-0d04-0410-961f-82ee72b054a4 --- 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 + + 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 * 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 + + 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 * 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)