From 091421018c0d22c4319830d2dbc2fd778d1cc778 Mon Sep 17 00:00:00 2001 From: Bernd Edlinger Date: Wed, 2 Oct 2019 13:22:37 +0000 Subject: [PATCH] backport: re PR fortran/91716 (ICE in output_constant, at varasm.c:5026) 2019-10-02 Bernd Edlinger Backport from mainline 2019-09-13 Bernd Edlinger PR fortran/91716 * trans-array.c (gfc_conv_array_initializer): Always assign the array type of the field to the string constant. PR fortran/91716 * gfortran.dg/pr91716.f90: New test. From-SVN: r276458 --- gcc/ChangeLog | 10 ++++++++++ gcc/fortran/trans-array.c | 11 +++++++---- gcc/testsuite/ChangeLog | 9 +++++++++ 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index b36097160f44..1e9c050d45a0 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,13 @@ +2019-10-02 Bernd Edlinger + + Backport from mainline + + 2019-09-13 Bernd Edlinger + + PR fortran/91716 + * trans-array.c (gfc_conv_array_initializer): Always assign the + array type of the field to the string constant. + 2019-10-01 Oleg Endo Backport from mainline diff --git a/gcc/fortran/trans-array.c b/gcc/fortran/trans-array.c index 583425c516da..9e1f159a6965 100644 --- a/gcc/fortran/trans-array.c +++ b/gcc/fortran/trans-array.c @@ -6110,17 +6110,20 @@ gfc_conv_array_initializer (tree type, gfc_expr * expr) tree atype = type; while (TREE_CODE (TREE_TYPE (atype)) == ARRAY_TYPE) atype = TREE_TYPE (atype); - if (TREE_CODE (TREE_TYPE (atype)) == INTEGER_TYPE - && tree_to_uhwi (TYPE_SIZE_UNIT (TREE_TYPE (se.expr))) - > tree_to_uhwi (TYPE_SIZE_UNIT (atype))) + gcc_checking_assert (TREE_CODE (TREE_TYPE (atype)) + == INTEGER_TYPE); + gcc_checking_assert (TREE_TYPE (TREE_TYPE (se.expr)) + == TREE_TYPE (atype)); + if (tree_to_uhwi (TYPE_SIZE_UNIT (TREE_TYPE (se.expr))) + > tree_to_uhwi (TYPE_SIZE_UNIT (atype))) { unsigned HOST_WIDE_INT size = tree_to_uhwi (TYPE_SIZE_UNIT (atype)); const char *p = TREE_STRING_POINTER (se.expr); se.expr = build_string (size, p); - TREE_TYPE (se.expr) = atype; } + TREE_TYPE (se.expr) = atype; } break; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index f6095aba8fdd..362ed17d1b13 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,12 @@ +2019-10-02 Bernd Edlinger + + Backport from mainline + + 2019-09-13 Bernd Edlinger + + PR fortran/91716 + * gfortran.dg/pr91716.f90: New test. + 2019-10-01 Steven G. Kargl PR fortran/91864 -- 2.47.2