This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] PR fortran/78479 -- allocate a charlen
- From: Steve Kargl <sgk at troutmask dot apl dot washington dot edu>
- To: fortran at gcc dot gnu dot org, gcc-patches at gcc dot gnu dot org
- Date: Tue, 22 Nov 2016 12:55:57 -0800
- Subject: [PATCH] PR fortran/78479 -- allocate a charlen
- Authentication-results: sourceware.org; auth=none
- Reply-to: kargl at uw dot edu
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