From: Steven G. Kargl Date: Tue, 22 Nov 2016 21:52:15 +0000 (+0000) Subject: re PR fortran/78479 (ICE in gfc_apply_init, at fortran/expr.c:4135) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=7e98cccbd85a0bc5ec6b7edf0017d98c2e96aef5;p=gcc.git 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 --- 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