From 1eabf876d50f6b9041fb36b5229a8b6634773d3e Mon Sep 17 00:00:00 2001 From: Thomas Koenig Date: Tue, 12 Mar 2019 17:22:28 +0000 Subject: [PATCH] re PR fortran/87673 (Errors caused by using function for character length in allocate with typespec) 2019-03-12 Thomas Koenig PR fortran/87673 * match.c (gfc_match_type_spec): Remove call to gfc_resolve_expr for character length. 2019-03-12 Thomas Koenig PR fortran/87673 * gfortran.dg/charlen_17.f90: New test. From-SVN: r269624 --- gcc/fortran/ChangeLog | 6 ++++++ gcc/fortran/match.c | 2 -- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gfortran.dg/charlen_17.f90 | 14 ++++++++++++++ 4 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gfortran.dg/charlen_17.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 49825741b95..edcacf50231 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2019-03-12 Thomas Koenig + + PR fortran/87673 + * match.c (gfc_match_type_spec): Remove call to + gfc_resolve_expr for character length. + 2019-03-12 Martin Liska * decl.c (add_init_expr_to_sym): Replace usage of 'can't' diff --git a/gcc/fortran/match.c b/gcc/fortran/match.c index 9ff1c35b2a0..eba428fd084 100644 --- a/gcc/fortran/match.c +++ b/gcc/fortran/match.c @@ -2122,8 +2122,6 @@ gfc_match_type_spec (gfc_typespec *ts) ts->type = BT_CHARACTER; m = gfc_match_char_spec (ts); - if (ts->u.cl && ts->u.cl->length) - gfc_resolve_expr (ts->u.cl->length); if (m == MATCH_NO) m = MATCH_YES; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index a640b6a643b..edde1c1689e 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-03-12 Thomas Koenig + + PR fortran/87673 + * gfortran.dg/charlen_17.f90: New test. + 2019-03-12 Robin Dapp * gcc.target/s390/memset-1.c: Adapt test case for new scheduling. diff --git a/gcc/testsuite/gfortran.dg/charlen_17.f90 b/gcc/testsuite/gfortran.dg/charlen_17.f90 new file mode 100644 index 00000000000..6b766d8f433 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/charlen_17.f90 @@ -0,0 +1,14 @@ +! { dg-do compile } +! PR 87673 - used to cause errors about non-pure functions. + +module x + implicit none +contains + pure function foo() result(res) + character(len=:), allocatable :: res + allocate (character(bar()) :: res) + end function foo + pure integer function bar() + bar = 1 + end function bar +end module x -- 2.30.2