diff mbox

Possible patch for 62242

Message ID 14ee2f0fa04.1099515e221024.4229538263700683629@zoho.com
State New
Headers show

Commit Message

Louis Krupp July 31, 2015, 7:08 a.m. UTC
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.
diff mbox

Patch

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,