[PATCH, fortran, 4.5] Fix constant folding of noninteger exponents.

Paul Richard Thomas paul.richard.thomas@gmail.com
Tue Feb 24 21:31:00 GMT 2009


Dear All,

> PS The ICE occurs at a place in gfc_conv_array_initializer that I have
> often eyed in the past.  I wonder if upon detecting and EXP_OP that is
> a constant expression that we should not convert it?  With the best
> will in the world, some things might not simplify but still be
> detected if outside of the standard.  This would be a useful safety
> net that would have fixed this bug.

Thusly:

Index: gcc/fortran/trans-array.c
===================================================================
--- gcc/fortran/trans-array.c	(revision 144163)
+++ gcc/fortran/trans-array.c	(working copy)
@@ -4005,6 +4005,21 @@
 	      CONSTRUCTOR_APPEND_ELT (v, index, se.expr);
 	      break;

+	    case EXPR_OP:
+	      /* Catch those occasional beasts that do not simplify
+		 for one reason or another, assuming that if they are
+		 standard defying the frontend will catch them.  */
+	      gfc_conv_expr (&se, c->expr);
+              if (range == NULL_TREE)
+		CONSTRUCTOR_APPEND_ELT (v, index, se.expr);
+              else
+                {
+                  if (index != NULL_TREE)
+		    CONSTRUCTOR_APPEND_ELT (v, index, se.expr);
+		  CONSTRUCTOR_APPEND_ELT (v, range, se.expr);
+                }
+	      break;
+
 	    default:
 	      gcc_unreachable ();
 	    }

This fixes both your problem and PR39292.  Note that I am not
proposing this as an alternative, since we should simplify when
possible, but as a safety net.

Cheers

Paul



More information about the Gcc-patches mailing list