backport: re PR fortran/83864 (ICE in gfc_apply_init, at fortran/expr.c:4271)

2018-01-18  Harald Anlauf  <anlauf@gmx.de>

	Backport from mainline
	PR fortran/83864
	* expr.c (gfc_apply_init): Do not dereference NULL pointer.

2018-01-18  Harald Anlauf  <anlauf@gmx.de>

	Backport from mainline
	PR fortran/83864
	* gfortran.dg/pr83864.f90: New test.

From-SVN: r256857
This commit is contained in:
Harald Anlauf 2018-01-18 18:27:22 +00:00 committed by Steven G. Kargl
parent 4a560547e3
commit 8f87c1ab9b
4 changed files with 27 additions and 1 deletions

View File

@ -1,3 +1,9 @@
2018-01-18 Harald Anlauf <anlauf@gmx.de>
Backport from mainline
PR fortran/83864
* expr.c (gfc_apply_init): Do not dereference NULL pointer.
2018-01-17 Harald Anlauf <anlauf@gmx.de>
Backport from mainline

View File

@ -4130,7 +4130,8 @@ gfc_apply_init (gfc_typespec *ts, symbol_attribute *attr, gfc_expr *init)
if (init->expr_type == EXPR_CONSTANT)
gfc_set_constant_character_len (len, init, -1);
else if (init
&& init->ts.u.cl
&& init->ts.type == BT_CHARACTER
&& init->ts.u.cl && init->ts.u.cl->length
&& mpz_cmp (ts->u.cl->length->value.integer,
init->ts.u.cl->length->value.integer))
{

View File

@ -1,3 +1,9 @@
2018-01-18 Harald Anlauf <anlauf@gmx.de>
Backport from mainline
PR fortran/83864
* gfortran.dg/pr83864.f90: New test.
2018-01-17 Bill Schmidt <wschmidt@linux.vnet.ibm.com>
Backport from mainline

View File

@ -0,0 +1,13 @@
! { dg-do run }
! PR fortran/83864
!
! Derived from PR by Contributed by Gerhard Steinmetz <gscfq@t-online.de>
!
program p
implicit none
type t
character :: c(3) = transfer('abc','z',3)
end type t
type(t) :: x
if (any (x%c /= ["a", "b", "c"])) call abort ()
end