Commit 22cd0312 by Bernd Edlinger Committed by Bernd Edlinger

re PR fortran/91716 (ICE in output_constant, at varasm.c:5026)

2019-09-13  Bernd Edlinger  <bernd.edlinger@hotmail.de>

        PR fortran/91716
        * trans-array.c (gfc_conv_array_initializer): Always assign the
        array type of the field to the string constant.

testsuite:
2019-09-13  Bernd Edlinger  <bernd.edlinger@hotmail.de>

        PR fortran/91716
        * gfortran.dg/pr91716.f90: New test.

From-SVN: r275698
parent 0d1cfeed
2019-09-13 Bernd Edlinger <bernd.edlinger@hotmail.de>
PR fortran/91716
* trans-array.c (gfc_conv_array_initializer): Always assign the
array type of the field to the string constant.
2019-09-13 Paul Thomas <pault@gcc.gnu.org> 2019-09-13 Paul Thomas <pault@gcc.gnu.org>
PR fortran/91717 PR fortran/91717
......
...@@ -6108,17 +6108,20 @@ gfc_conv_array_initializer (tree type, gfc_expr * expr) ...@@ -6108,17 +6108,20 @@ gfc_conv_array_initializer (tree type, gfc_expr * expr)
tree atype = type; tree atype = type;
while (TREE_CODE (TREE_TYPE (atype)) == ARRAY_TYPE) while (TREE_CODE (TREE_TYPE (atype)) == ARRAY_TYPE)
atype = TREE_TYPE (atype); atype = TREE_TYPE (atype);
if (TREE_CODE (TREE_TYPE (atype)) == INTEGER_TYPE gcc_checking_assert (TREE_CODE (TREE_TYPE (atype))
&& tree_to_uhwi (TYPE_SIZE_UNIT (TREE_TYPE (se.expr))) == INTEGER_TYPE);
> tree_to_uhwi (TYPE_SIZE_UNIT (atype))) 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 unsigned HOST_WIDE_INT size
= tree_to_uhwi (TYPE_SIZE_UNIT (atype)); = tree_to_uhwi (TYPE_SIZE_UNIT (atype));
const char *p = TREE_STRING_POINTER (se.expr); const char *p = TREE_STRING_POINTER (se.expr);
se.expr = build_string (size, p); se.expr = build_string (size, p);
TREE_TYPE (se.expr) = atype;
} }
TREE_TYPE (se.expr) = atype;
} }
break; break;
......
2019-09-13 Bernd Edlinger <bernd.edlinger@hotmail.de>
PR fortran/91716
* gfortran.dg/pr91716.f90: New test.
2019-09-13 Paul Thomas <pault@gcc.gnu.org> 2019-09-13 Paul Thomas <pault@gcc.gnu.org>
PR fortran/91717 PR fortran/91717
......
! { dg-do compile }
! PR fortran/91716
! Code contributed by Gerhard Steinmetz
module m
type t
character :: c(2) = [character(-1) :: 'a', 'b']
end type
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment