Index: fold-const.c =================================================================== --- fold-const.c (revision 127204) +++ fold-const.c (working copy) @@ -3277,6 +3277,11 @@ omit_one_operand (tree type, tree 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)) return build2 (COMPOUND_EXPR, type, fold_ignored_result (omitted), t); @@ -3290,6 +3295,11 @@ pedantic_omit_one_operand (tree type, tr { 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: testsuite/gfortran.fortran-torture/compile/emptyif-1.f90 =================================================================== --- testsuite/gfortran.fortran-torture/compile/emptyif-1.f90 (revision 0) +++ testsuite/gfortran.fortran-torture/compile/emptyif-1.f90 (revision 0) @@ -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: testsuite/lib/fortran-torture.exp =================================================================== --- testsuite/lib/fortran-torture.exp (revision 127204) +++ testsuite/lib/fortran-torture.exp (working copy) @@ -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)