From 524cee402e974b7e8e6e8e7ca6af189360c99526 Mon Sep 17 00:00:00 2001 From: Paul Thomas Date: Sat, 23 Feb 2019 13:18:47 +0000 Subject: [PATCH] re PR fortran/88117 (ICE in gimplify_var_or_parm_decl, at gimplify.c:2697) 2019-02-23 Paul Thomas PR fortran/88117 * resolve.c (deferred_op_assign): Return if the lhs expression has the pointer attribute. * trans-expr.c (gfc_trans_assignment_1): Do not fix the string length if the lhs expression has the pointer attribute. 2019-02-23 Paul Thomas PR fortran/88117 * gfortran.dg/deferred_character_32.f90 : New test From-SVN: r269157 --- gcc/fortran/ChangeLog | 8 ++++++++ gcc/fortran/resolve.c | 3 +++ gcc/fortran/trans-expr.c | 4 +++- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gfortran.dg/deferred_character_32.f90 | 13 +++++++++++++ 5 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gfortran.dg/deferred_character_32.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 3b5028cd0c2..f03302e73a3 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,11 @@ +2019-02-23 Paul Thomas + + PR fortran/88117 + * resolve.c (deferred_op_assign): Return if the lhs expression + has the pointer attribute. + * trans-expr.c (gfc_trans_assignment_1): Do not fix the string + length if the lhs expression has the pointer attribute. + 2019-02-23 Paul Thomas PR fortran/89385 diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c index e581a60f157..422cec29cdd 100644 --- a/gcc/fortran/resolve.c +++ b/gcc/fortran/resolve.c @@ -11166,6 +11166,9 @@ deferred_op_assign (gfc_code **code, gfc_namespace *ns) if (!gfc_check_dependency ((*code)->expr1, (*code)->expr2, 1)) return false; + if (gfc_expr_attr ((*code)->expr1).pointer) + return false; + tmp_expr = get_temp_from_expr ((*code)->expr1, ns); tmp_expr->where = (*code)->loc; diff --git a/gcc/fortran/trans-expr.c b/gcc/fortran/trans-expr.c index cff3d7c2930..a865cd6adeb 100644 --- a/gcc/fortran/trans-expr.c +++ b/gcc/fortran/trans-expr.c @@ -10579,7 +10579,9 @@ gfc_trans_assignment_1 (gfc_expr * expr1, gfc_expr * expr2, bool init_flag, string_length = gfc_evaluate_now (rse.string_length, &rse.pre); else if (expr2->ts.type == BT_CHARACTER) { - if (expr1->ts.deferred && gfc_check_dependency (expr1, expr2, true)) + if (expr1->ts.deferred + && gfc_expr_attr (expr1).allocatable + && gfc_check_dependency (expr1, expr2, true)) rse.string_length = gfc_evaluate_now (rse.string_length, &rse.pre); string_length = rse.string_length; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 0d1cdecd6df..cc5a87d5cc7 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-02-23 Paul Thomas + + PR fortran/88117 + * gfortran.dg/deferred_character_32.f90 : New test + 2019-02-23 Paul Thomas PR fortran/89385 diff --git a/gcc/testsuite/gfortran.dg/deferred_character_32.f90 b/gcc/testsuite/gfortran.dg/deferred_character_32.f90 new file mode 100644 index 00000000000..3969d97ffc9 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/deferred_character_32.f90 @@ -0,0 +1,13 @@ +! { dg-do run } +! +! Test the fix for PR88117. +! +! Contributed by Gerhard Steinmetz +! +program p + character(:), pointer :: z(:) + allocate (z, source = ['abcd', 'bcde']) + z = (z) ! gimplifier choked here. + if (any (z .ne. ['abcd', 'bcde'])) stop 1 + deallocate (z) +end -- 2.30.2