From 7e98cccbd85a0bc5ec6b7edf0017d98c2e96aef5 Mon Sep 17 00:00:00 2001 From: "Steven G. Kargl" Date: Tue, 22 Nov 2016 21:52:15 +0000 Subject: [PATCH] re PR fortran/78479 (ICE in gfc_apply_init, at fortran/expr.c:4135) 2016-11-22 Steven G. Kargl PR fortran/78479 * expr.c (gfc_apply_init): Allocate a charlen if needed. 2016-11-22 Steven G. Kargl PR fortran/78479 * gfortran.dg/char_component_initializer_3.f90: New test. From-SVN: r242725 --- gcc/fortran/ChangeLog | 5 +++++ gcc/fortran/expr.c | 7 ++++++- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gfortran.dg/char_component_initializer_3.f90 | 6 ++++++ 4 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gfortran.dg/char_component_initializer_3.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 48c533d1eaf..1ea1c2cbc9f 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,8 @@ +2016-11-22 Steven G. Kargl + + PR fortran/78479 + * expr.c (gfc_apply_init): Allocate a charlen if needed. + 2016-11-22 Janus Weil PR fortran/78443 diff --git a/gcc/fortran/expr.c b/gcc/fortran/expr.c index e2d1311d1a5..b028d81ba6d 100644 --- a/gcc/fortran/expr.c +++ b/gcc/fortran/expr.c @@ -4132,7 +4132,12 @@ gfc_apply_init (gfc_typespec *ts, symbol_attribute *attr, gfc_expr *init) { 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); } } } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index d18ad6dba08..bb5ce39e33d 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2016-11-22 Steven G. Kargl + + PR fortran/78479 + * gfortran.dg/char_component_initializer_3.f90: New test. + 2016-11-22 Jakub Jelinek PR target/78451 diff --git a/gcc/testsuite/gfortran.dg/char_component_initializer_3.f90 b/gcc/testsuite/gfortran.dg/char_component_initializer_3.f90 new file mode 100644 index 00000000000..634da4a8f69 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/char_component_initializer_3.f90 @@ -0,0 +1,6 @@ +! { dg-do compile } +program p + type t + character(3) :: c(1) = 'a' // ['b'] + end type +end -- 2.30.2