From bc1efcb737bc372cc46db8a57430e623da222508 Mon Sep 17 00:00:00 2001 From: Harald Anlauf Date: Mon, 4 Feb 2019 20:44:22 +0000 Subject: [PATCH] re PR fortran/89077 (ICE using * as len specifier for character parameter) 2019-02-04 Harald Anlauf PR fortran/89077 * gfortran.dg/pr89077.f90: New test. 2019-02-04 Harald Anlauf PR fortran/89077 * gfortran.dg/pr89077.f90: New test. From-SVN: r268525 --- gcc/fortran/ChangeLog | 6 ++++++ gcc/fortran/decl.c | 2 +- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gfortran.dg/pr89077.f90 | 11 +++++++++++ 4 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gfortran.dg/pr89077.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 1bd851a4b0e..03278652e11 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2019-02-04 Harald Anlauf + + PR fortran/89077 + * decl.c (add_init_expr_to_sym): Copy length of string initializer + to declared symbol. + 2019-02-04 Martin Liska PR fortran/89185 diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c index e798381467d..4393287e1f1 100644 --- a/gcc/fortran/decl.c +++ b/gcc/fortran/decl.c @@ -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. */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 7886a12ddf8..14db6287ff5 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-02-04 Harald Anlauf + + PR fortran/89077 + * gfortran.dg/pr89077.f90: New test. + 2019-02-04 Martin Liska PR ipa/88985 diff --git a/gcc/testsuite/gfortran.dg/pr89077.f90 b/gcc/testsuite/gfortran.dg/pr89077.f90 new file mode 100644 index 00000000000..26a0d2821bb --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr89077.f90 @@ -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 -- 2.30.2