re PR fortran/88117 (ICE in gimplify_var_or_parm_decl, at gimplify.c:2697)
authorPaul Thomas <pault@gcc.gnu.org>
Sat, 23 Feb 2019 13:18:47 +0000 (13:18 +0000)
committerPaul Thomas <pault@gcc.gnu.org>
Sat, 23 Feb 2019 13:18:47 +0000 (13:18 +0000)
2019-02-23  Paul Thomas  <pault@gcc.gnu.org>

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  <pault@gcc.gnu.org>

PR fortran/88117
* gfortran.dg/deferred_character_32.f90 : New test

From-SVN: r269157

gcc/fortran/ChangeLog
gcc/fortran/resolve.c
gcc/fortran/trans-expr.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/deferred_character_32.f90 [new file with mode: 0644]

index 3b5028cd0c2bce527c6a4baf03f11328f78151f0..f03302e73a373e0f280f356287386661a438d105 100644 (file)
@@ -1,3 +1,11 @@
+2019-02-23  Paul Thomas  <pault@gcc.gnu.org>
+
+       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  <pault@gcc.gnu.org>
 
        PR fortran/89385
index e581a60f157f41f1ea88764a56ab8b62b2ec9b8f..422cec29cdd9d17669f9f65ef161fcb942b456b7 100644 (file)
@@ -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;
 
index cff3d7c2930f1fc3ca6dc63fdc2944b738283771..a865cd6adeb93f16caec2d4538b73f2e50a9003f 100644 (file)
@@ -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;
     }
index 0d1cdecd6df72bf682740af83698d29b6d1d847b..cc5a87d5cc7213dd22eea4ac82f8b3840cd74c40 100644 (file)
@@ -1,3 +1,8 @@
+2019-02-23  Paul Thomas  <pault@gcc.gnu.org>
+
+       PR fortran/88117
+       * gfortran.dg/deferred_character_32.f90 : New test
+
 2019-02-23  Paul Thomas  <pault@gcc.gnu.org>
 
        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 (file)
index 0000000..3969d97
--- /dev/null
@@ -0,0 +1,13 @@
+! { dg-do run }
+!
+! Test the fix for PR88117.
+!
+! Contributed by Gerhard Steinmetz  <gscfq@t-online.de>
+!
+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