]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR fortran/89077 (ICE using * as len specifier for character parameter)
authorHarald Anlauf <anlauf@gmx.de>
Sun, 10 Feb 2019 20:05:34 +0000 (20:05 +0000)
committerHarald Anlauf <anlauf@gcc.gnu.org>
Sun, 10 Feb 2019 20:05:34 +0000 (20:05 +0000)
2019-02-10  Harald Anlauf  <anlauf@gmx.de>

Backport from trunk
PR fortran/89077
* decl.c (add_init_expr_to_sym): Copy length of string initializer
to declared symbol.

PR fortran/89077
* gfortran.dg/pr89077.f90: New test.

From-SVN: r268753

gcc/fortran/ChangeLog
gcc/fortran/decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/pr89077.f90 [new file with mode: 0644]

index 282d863655c246f1081a29ad91a69a5684dec310..01373f0e9e9892ab041015538394acde511b4f78 100644 (file)
@@ -1,3 +1,10 @@
+2019-02-10  Harald Anlauf  <anlauf@gmx.de>
+
+       Backport from trunk
+       PR fortran/89077
+       * decl.c (add_init_expr_to_sym): Copy length of string initializer
+       to declared symbol.
+
 2019-02-10  Thomas Koenig  <tkoenig@gcc.gnu.org>
 
        PR fortran/71723
index 2f69028ac2c060e7f4089cf204ee6c49a60058ff..4aef1ac34173dbb597310c142588d29baf1c3088 100644 (file)
@@ -1796,7 +1796,7 @@ add_init_expr_to_sym (const char *name, gfc_expr **initp, locus *var_locus)
                    }
                  else if (init->ts.u.cl && init->ts.u.cl->length)
                    sym->ts.u.cl->length =
-                               gfc_copy_expr (sym->value->ts.u.cl->length);
+                               gfc_copy_expr (init->ts.u.cl->length);
                }
            }
          /* Update initializer character length according symbol.  */
index 7397586bdb86e26115452de05742e39904722e79..02f051e6cbd7fe9eef677a91723f31f25d3303a3 100644 (file)
@@ -1,3 +1,9 @@
+2019-02-10  Harald Anlauf  <anlauf@gmx.de>
+
+       Backport from trunk
+       PR fortran/89077
+       * gfortran.dg/pr89077.f90: New test.
+
 2019-02-10  Thomas Koenig  <tkoenig@gcc.gnu.org>
 
        PR fortran/71723
diff --git a/gcc/testsuite/gfortran.dg/pr89077.f90 b/gcc/testsuite/gfortran.dg/pr89077.f90
new file mode 100644 (file)
index 0000000..26a0d28
--- /dev/null
@@ -0,0 +1,11 @@
+! { dg-do run }
+!
+! PR fortran/89077 - ICE using * as len specifier for character parameter
+
+program test
+  implicit none
+  integer :: i
+  character(*), parameter :: s = 'abcdef'
+  character(*), parameter :: t = transfer ([(s(i:i), i=1,len(s))], s)
+  if (len (t) /= len (s) .or. t /= s) stop 1
+end