2007-08-09 Andrew Pinski <andrew_pinski@playstation.sony.com>
authorpinskia <pinskia@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 9 Aug 2007 21:36:27 +0000 (21:36 +0000)
committerpinskia <pinskia@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 9 Aug 2007 21:36:27 +0000 (21:36 +0000)
        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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@127322 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/fold-const.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.fortran-torture/compile/emptyif-1.f90 [new file with mode: 0644]
gcc/testsuite/lib/fortran-torture.exp

index f9cfb2e..410cf54 100644 (file)
@@ -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.
index eadcb97..d5d0f1e 100644 (file)
@@ -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);
 
index 5dd66c3..06b2fff 100644 (file)
@@ -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 (file)
index 0000000..bdce67d
--- /dev/null
@@ -0,0 +1,10 @@
+program emptyif
+
+  implicit none
+  integer i,K(4)
+
+  if (K(i)==0) then
+    ! do absolutely nothing
+  end if
+
+end program
index 8bc5978..d97c2ce 100644 (file)
@@ -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)