public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Fix middle-end/32813 ICE in annotate_all_with_locus
@ 2007-08-04 11:41 Andrew Pinski
  2007-08-08  0:39 ` Ian Lance Taylor
  0 siblings, 1 reply; 2+ messages in thread
From: Andrew Pinski @ 2007-08-04 11:41 UTC (permalink / raw)
  To: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 1107 bytes --]

Hi,
  The fortran front-end calls annotate_all_with_locus with a statement
list which included coumpound statement which was generated by fold
and annotate_all_with_locus does not like the compound expression at
all.  The compound expression was generated when fold was folding
COND_EXPR<SAVE_EXPR, EMPTY_STMT, EMPTY_STMT> and decided it needed to
keep around the SAVE_EXPR (which is correct).  Since we really don't
need to generate a compound expression here, I changed
omit_one_operand and pedantic_omit_one_operand for this case to just
return a cast to void type of the ommited expression.

I also had to fix up gfortran.fortran-torture/compile to run through
all the options instead of just -O.

OK?  Bootstrapped and tested on i686-apple-darwin8.10 with no regressions.

Thanks,
Andrew Pinski

ChangeLog:

* fold-const.c (omit_one_operand): Return only the ommitted expression
if the result is an empty statement.
(pedantic_omit_one_operand): Likewise.


* gfortran.fortran-torture/compile/emptyif-1.f90: New test.
* lib/fortran-torture.exp (fortran-torture): Use TORTURE_OPTIONS instead
of just -O.

[-- Attachment #2: fixpr32813.diff.txt --]
[-- Type: text/plain, Size: 2280 bytes --]

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)

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] Fix middle-end/32813 ICE in annotate_all_with_locus
  2007-08-04 11:41 [PATCH] Fix middle-end/32813 ICE in annotate_all_with_locus Andrew Pinski
@ 2007-08-08  0:39 ` Ian Lance Taylor
  0 siblings, 0 replies; 2+ messages in thread
From: Ian Lance Taylor @ 2007-08-08  0:39 UTC (permalink / raw)
  To: Andrew Pinski; +Cc: gcc-patches

"Andrew Pinski" <pinskia@gmail.com> writes:

> * fold-const.c (omit_one_operand): Return only the ommitted expression
> if the result is an empty statement.
> (pedantic_omit_one_operand): Likewise.

This patch is OK.

> * gfortran.fortran-torture/compile/emptyif-1.f90: New test.
> * lib/fortran-torture.exp (fortran-torture): Use TORTURE_OPTIONS instead
> of just -O.

Ask the fortran folks about this part.

Thanks.

Ian

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2007-08-08  0:39 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-08-04 11:41 [PATCH] Fix middle-end/32813 ICE in annotate_all_with_locus Andrew Pinski
2007-08-08  0:39 ` Ian Lance Taylor

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).