This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] PR fortran/78479 -- allocate a charlen


The patch and ChangeLog shuod be sufficient to explain the change.
Regression tested on x86_64-*-freebsd.  OK to commit?

2016-11-22  Steven G. Kargl  <kargl@gcc.gnu.org>

	PR fortran/78479
	* expr.c (gfc_apply_init):  Allocate a charlen if needed.

2016-11-22  Steven G. Kargl  <kargl@gcc.gnu.org>

	PR fortran/78479
	* gfortran.dg/pr78479.f90: New test.

-- 
Steve
Index: gcc/fortran/expr.c
===================================================================
--- gcc/fortran/expr.c	(revision 242638)
+++ gcc/fortran/expr.c	(working copy)
@@ -4132,7 +4132,12 @@ gfc_apply_init (gfc_typespec *ts, symbol
                 {
                   gfc_set_constant_character_len (len, ctor->expr,
                                                   has_ts ? -1 : first_len);
-                  ctor->expr->ts.u.cl->length = gfc_copy_expr (ts->u.cl->length);
+		  if (!ctor->expr->ts.u.cl)
+		    ctor->expr->ts.u.cl
+		      = gfc_new_charlen (gfc_current_ns, ts->u.cl);
+		  else
+                    ctor->expr->ts.u.cl->length
+		      = gfc_copy_expr (ts->u.cl->length);
                 }
             }
         }
Index: gcc/testsuite/gfortran.dg/pr78479.f90
===================================================================
--- gcc/testsuite/gfortran.dg/pr78479.f90	(nonexistent)
+++ gcc/testsuite/gfortran.dg/pr78479.f90	(working copy)
@@ -0,0 +1,6 @@
+! { dg-do compile }
+program p
+   type t
+      character(3) :: c(1) = 'a' // ['b']
+   end type
+end

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]