Possible patch for 62242

Louis Krupp louis.krupp@zoho.com
Fri Jul 31 16:40:00 GMT 2015


As far as I can tell, the problem in 62242 (and possibly 62246) is with a string array constructor trying to deal with an array element whose value is a character function that is described in an interface block and which has an assumed-length result.  I can't claim more than a superficial understanding of the code, but this patch seems to work.  I ran make check-fortran, and I saw no regressions.

Index: gcc/fortran/ChangeLog
===================================================================
--- gcc/fortran/ChangeLog    (revision 226427)
+++ gcc/fortran/ChangeLog    (working copy)
@@ -1877,6 +1877,12 @@
     * interface.c (is_procptr_result): New function to check if an
     expression is a procedure-pointer result.
     (compare_actual_formal): Use it.
+
+2015_07-31
+
+    PR fortran/62242
+    * trans-array.c (gfc_add_loop_ss_code): String array constructor:
+    Don't try to convert string length unless it's constant.
 ^L
 Copyright (C) 2015 Free Software Foundation, Inc.
 
Index: gcc/fortran/trans-array.c
===================================================================
--- gcc/fortran/trans-array.c    (revision 226427)
+++ gcc/fortran/trans-array.c    (working copy)
@@ -2589,7 +2589,8 @@ gfc_add_loop_ss_code (gfc_loopinfo * loop, gfc_ss
       if (expr->ts.type == BT_CHARACTER
           && ss_info->string_length == NULL
           && expr->ts.u.cl
-          && expr->ts.u.cl->length)
+          && expr->ts.u.cl->length
+          && expr->ts.u.cl->length->expr_type == EXPR_CONSTANT)
         {
           gfc_init_se (&se, NULL);
           gfc_conv_expr_type (&se, expr->ts.u.cl->length,
-------------- next part --------------
A non-text attachment was scrubbed...
Name: string_array_constructor_1.f90
Type: application/octet-stream
Size: 771 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20150731/164cad5d/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: string_array_constructor_2.f90
Type: application/octet-stream
Size: 1280 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20150731/164cad5d/attachment-0001.obj>


More information about the Fortran mailing list