]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR fortran/91716 (ICE in output_constant, at varasm.c:5026)
authorBernd Edlinger <bernd.edlinger@hotmail.de>
Wed, 2 Oct 2019 13:22:37 +0000 (13:22 +0000)
committerBernd Edlinger <edlinger@gcc.gnu.org>
Wed, 2 Oct 2019 13:22:37 +0000 (13:22 +0000)
2019-10-02  Bernd Edlinger  <bernd.edlinger@hotmail.de>

        Backport from mainline

        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.

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

From-SVN: r276458

gcc/ChangeLog
gcc/fortran/trans-array.c
gcc/testsuite/ChangeLog

index b36097160f44e836abc7ff3baa71536cf35c1cb3..1e9c050d45a08a8ce5176ebb9197729016d8e3d9 100644 (file)
@@ -1,3 +1,13 @@
+2019-10-02  Bernd Edlinger  <bernd.edlinger@hotmail.de>
+
+       Backport from mainline
+
+       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-10-01  Oleg Endo  <olegendo@gcc.gnu.org>
 
        Backport from mainline
index 583425c516daf68dc49e37525d0186972242896a..9e1f159a69651c87717a7afd9113ec8639be8f43 100644 (file)
@@ -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;
 
index f6095aba8fdd9c770ce0ced039751a407f937659..362ed17d1b130a67a87bf993e245b40a424e7c3b 100644 (file)
@@ -1,3 +1,12 @@
+2019-10-02  Bernd Edlinger  <bernd.edlinger@hotmail.de>
+
+       Backport from mainline
+
+       2019-09-13  Bernd Edlinger  <bernd.edlinger@hotmail.de>
+
+       PR fortran/91716
+       * gfortran.dg/pr91716.f90: New test.
+
 2019-10-01 Steven G. Kargl  <kargl@gcc.gnu.org>
 
        PR fortran/91864