re PR fortran/89077 (ICE using * as len specifier for character parameter)
authorHarald Anlauf <anlauf@gmx.de>
Mon, 4 Feb 2019 20:44:22 +0000 (20:44 +0000)
committerHarald Anlauf <anlauf@gcc.gnu.org>
Mon, 4 Feb 2019 20:44:22 +0000 (20:44 +0000)
2019-02-04  Harald Anlauf  <anlauf@gmx.de>

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

2019-02-04  Harald Anlauf  <anlauf@gmx.de>

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

From-SVN: r268525

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

index 1bd851a4b0e1adf53951b193e25d782052b0641e..03278652e110a2399cb730b17b6691a06c6f0525 100644 (file)
@@ -1,3 +1,9 @@
+2019-02-04  Harald Anlauf  <anlauf@gmx.de>
+
+       PR fortran/89077
+       * decl.c (add_init_expr_to_sym): Copy length of string initializer
+       to declared symbol.
+
 2019-02-04  Martin Liska  <mliska@suse.cz>
 
        PR fortran/89185
index e798381467ddb01e985d8eef30f0b48ab419e2fe..4393287e1f1c0937194dca01e2882fba7072a898 100644 (file)
@@ -1921,7 +1921,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 7886a12ddf8087c17101b26a6e4bcde6bdea1914..14db6287ff5e4ade766f6f2bccf9d14724a7a29f 100644 (file)
@@ -1,3 +1,8 @@
+2019-02-04  Harald Anlauf  <anlauf@gmx.de>
+
+       PR fortran/89077
+       * gfortran.dg/pr89077.f90: New test.
+
 2019-02-04  Martin Liska  <mliska@suse.cz>
 
        PR ipa/88985
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