re PR fortran/33733 (ICEs in simplify_transfer)
authorPaul Thomas <pault@gcc.gnu.org>
Thu, 18 Oct 2007 12:44:03 +0000 (12:44 +0000)
committerPaul Thomas <pault@gcc.gnu.org>
Thu, 18 Oct 2007 12:44:03 +0000 (12:44 +0000)
2007-10-18  Paul Thomas  <pault@gcc.gnu.org>
    Dominique d'Humieres  <dominiq@lps.ens.fr>

PR fortran/33733
* simplify.c (gfc_simplify_transfer): Return null if the source
expression is EXPR_FUNCTION.

2007-10-18  Paul Thomas  <pault@gcc.gnu.org>

PR fortran/33733
* gfortran.dg/transfer_simplify_6.f90: New test.

From-SVN: r129435

gcc/fortran/simplify.c
gcc/testsuite/gfortran.dg/transfer_simplify_6.f90 [new file with mode: 0644]

index c9885dd..0bb13c1 100644 (file)
@@ -4011,6 +4011,9 @@ gfc_simplify_transfer (gfc_expr *source, gfc_expr *mold, gfc_expr *size)
        || !gfc_is_constant_expr (size))
     return NULL;
 
+  if (source->expr_type == EXPR_FUNCTION)
+    return NULL;
+
   /* Calculate the size of the source.  */
   if (source->expr_type == EXPR_ARRAY
       && gfc_array_size (source, &tmp) == FAILURE)
diff --git a/gcc/testsuite/gfortran.dg/transfer_simplify_6.f90 b/gcc/testsuite/gfortran.dg/transfer_simplify_6.f90
new file mode 100644 (file)
index 0000000..b557c06
--- /dev/null
@@ -0,0 +1,9 @@
+! { dg-do compile }
+! Checks the fix for PR33733, in which the functions of arrays
+! for the 'source' argument would cause an ICE.
+!
+! Contributed by FX Coudert <fxcoudert@gcc.gnu.org>
+!
+  print *, transfer(sqrt([100.]), 0_1)
+  print *, transfer(achar([100]), 0_1)
+end