From 36b54ce08eb893b4eac8ab8c27fde53249cf1b2c Mon Sep 17 00:00:00 2001 From: Thomas Koenig Date: Sat, 9 Jul 2016 22:18:29 +0000 Subject: [PATCH] re PR fortran/71783 (ICE on valid code in gimplify_var_or_parm_decl at gimplify.c:1801) 2016-07-09 Thomas Koenig PR fortran/71783 * frontend-passes.c (create_var): Always allocate a charlen for character variables. 2016-07-09 Thomas Koenig PR fortran/71783 * gfortran.dg/dependency_46.f90: New test. From-SVN: r238192 --- gcc/fortran/ChangeLog | 6 ++++++ gcc/fortran/frontend-passes.c | 6 ++---- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gfortran.dg/dependency_46.f90 | 11 +++++++++++ 4 files changed, 24 insertions(+), 4 deletions(-) create mode 100644 gcc/testsuite/gfortran.dg/dependency_46.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 61bd1af..8b71025 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2016-07-09 Thomas Koenig + + PR fortran/71783 + * frontend-passes.c (create_var): Always allocate a charlen + for character variables. + 2016-07-08 Steven G. Kargl PR fortran/68426 diff --git a/gcc/fortran/frontend-passes.c b/gcc/fortran/frontend-passes.c index f02a52a..9ae3421 100644 --- a/gcc/fortran/frontend-passes.c +++ b/gcc/fortran/frontend-passes.c @@ -665,12 +665,10 @@ create_var (gfc_expr * e, const char *vname) { gfc_expr *length; + symbol->ts.u.cl = gfc_new_charlen (ns, NULL); length = constant_string_length (e); if (length) - { - symbol->ts.u.cl = gfc_new_charlen (ns, NULL); - symbol->ts.u.cl->length = length; - } + symbol->ts.u.cl->length = length; else symbol->attr.allocatable = 1; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 1d83581..63333ba 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2016-07-09 Thomas Koenig + + PR fortran/71783 + * gfortran.dg/dependency_46.f90: New test. + 2016-07-08 Vladimir Makarov PR rtl-optimization/71621 diff --git a/gcc/testsuite/gfortran.dg/dependency_46.f90 b/gcc/testsuite/gfortran.dg/dependency_46.f90 new file mode 100644 index 0000000..28942a8 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/dependency_46.f90 @@ -0,0 +1,11 @@ +! { dg-do compile } +! PR 71783 - this used to ICE due to a missing charlen for the temporary. +! Test case by Toon Moene. + +SUBROUTINE prtdata(ilen) + INTEGER :: ilen + character(len=ilen), allocatable :: cline(:) + allocate(cline(2)) + cline(1) = 'a' + cline(2) = cline(1) +END SUBROUTINE prtdata -- 2.7.4