aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/ChangeLog7
-rw-r--r--gcc/fold-const.c10
-rw-r--r--gcc/testsuite/ChangeLog7
-rw-r--r--gcc/testsuite/gfortran.fortran-torture/compile/emptyif-1.f9010
-rw-r--r--gcc/testsuite/lib/fortran-torture.exp3
5 files changed, 36 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index f9cfb2e8908..410cf5470cd 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 eadcb97f7ce..d5d0f1e3c11 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 5dd66c3f72c..06b2fff2e7d 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 00000000000..bdce67db9ea
--- /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 8bc5978d89b..d97c2cefc61 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)