From 5954faa7c22d550ec57e9a40e5a738630be07b0f Mon Sep 17 00:00:00 2001 From: "Steven G. Kargl" Date: Fri, 8 Jun 2018 19:06:20 +0000 Subject: [PATCH] re PR fortran/78571 (ICE in create_character_initializer, at fortran/data.c:191) 2018-06-08 Steven G. Kargl PR fortran/78571 * data.c (create_character_initializer): Return early if type is incompatible with CHARACTER. 2018-06-08 Steven G. Kargl PR fortran/78571 * gfortran.dg/pr78571.f90: New test. From-SVN: r261343 --- gcc/fortran/ChangeLog | 6 ++++++ gcc/fortran/data.c | 5 ++++- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gfortran.dg/pr78571.f90 | 9 +++++++++ 4 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gfortran.dg/pr78571.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 7acc4c6c2fd..b48f11c2b67 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2018-06-08 Steven G. Kargl + + PR fortran/78571 + * data.c (create_character_initializer): Return early if type is + incompatible with CHARACTER. + 2018-06-07 Steven G. Kargl PR fortran/86045 diff --git a/gcc/fortran/data.c b/gcc/fortran/data.c index 780a5ad9564..d837e15ee28 100644 --- a/gcc/fortran/data.c +++ b/gcc/fortran/data.c @@ -107,7 +107,10 @@ create_character_initializer (gfc_expr *init, gfc_typespec *ts, HOST_WIDE_INT len, start, end, tlen; gfc_char_t *dest; bool alloced_init = false; - + + if (init && init->ts.type != BT_CHARACTER) + return NULL; + gfc_extract_hwi (ts->u.cl->length, &len); if (init == NULL) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 3b3bc5a7f15..a4d18b34b07 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-06-08 Steven G. Kargl + + PR fortran/78571 + * gfortran.dg/pr78571.f90: New test. + 2018-06-08 Peter Bergner PR target/85755 diff --git a/gcc/testsuite/gfortran.dg/pr78571.f90 b/gcc/testsuite/gfortran.dg/pr78571.f90 new file mode 100644 index 00000000000..16b07abd273 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr78571.f90 @@ -0,0 +1,9 @@ +! { dg-do compile } +! PR fortran/78571 +program p + type t + character :: c + end type + character :: x = t('a') ! { dg-error "convert TYPE" } + data x /'b'/ +end -- 2.30.2