re PR fortran/88304 (ICE in use_pointer_in_frame, at tree-nested.c:267)
authorJakub Jelinek <jakub@redhat.com>
Sat, 8 Dec 2018 13:37:49 +0000 (14:37 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Sat, 8 Dec 2018 13:37:49 +0000 (14:37 +0100)
PR fortran/88304
* tree-nested.c (convert_local_reference_stmt): Handle clobbers where
lhs is not a decl normally, don't call use_pointer_in_frame on that
lhs.

* gfortran.fortran-torture/compile/pr88304-2.f90: New test.

From-SVN: r266907

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.fortran-torture/compile/pr88304-2.f90 [new file with mode: 0644]
gcc/tree-nested.c

index 3da7dbe..f97a51e 100644 (file)
@@ -1,3 +1,10 @@
+2018-12-08  Jakub Jelinek  <jakub@redhat.com>
+
+       PR fortran/88304
+       * tree-nested.c (convert_local_reference_stmt): Handle clobbers where
+       lhs is not a decl normally, don't call use_pointer_in_frame on that
+       lhs.
+
 2018-12-08  Eric Botcazou  <ebotcazou@adacore.com>
 
        PR rtl-optimization/88390
index afa3d70..dc7c204 100644 (file)
@@ -1,3 +1,8 @@
+2018-12-08  Jakub Jelinek  <jakub@redhat.com>
+
+       PR fortran/88304
+       * gfortran.fortran-torture/compile/pr88304-2.f90: New test.
+
 2018-12-07  Paolo Carlini  <paolo.carlini@oracle.com>
 
        * g++.dg/other/bitfield7.C: New.
diff --git a/gcc/testsuite/gfortran.fortran-torture/compile/pr88304-2.f90 b/gcc/testsuite/gfortran.fortran-torture/compile/pr88304-2.f90
new file mode 100644 (file)
index 0000000..15bd451
--- /dev/null
@@ -0,0 +1,28 @@
+! PR fortran/88304
+
+module pr88304
+  implicit none
+  integer :: p
+contains
+  function foo (x, y, z, w)
+    integer, intent(in) :: x, y
+    character(*), optional, intent(out) :: z
+    integer, optional, intent(out) :: w
+    integer :: foo
+    foo = 1
+  end function foo
+  subroutine bar ()
+    integer :: s
+    s = baz (1)
+  contains
+    function baz (u)
+      integer, intent(in) :: u
+      integer :: baz
+      integer :: q
+      integer :: r (10)
+      r = 0
+      baz = 1
+      q = foo (p, r(u), w = baz)
+    end function baz
+  end subroutine bar
+end module pr88304
index ea54246..0ad469a 100644 (file)
@@ -2324,7 +2324,8 @@ convert_local_reference_stmt (gimple_stmt_iterator *gsi, bool *handled_ops_p,
       if (gimple_clobber_p (stmt))
        {
          tree lhs = gimple_assign_lhs (stmt);
-         if (!use_pointer_in_frame (lhs)
+         if (DECL_P (lhs)
+             && !use_pointer_in_frame (lhs)
              && lookup_field_for_decl (info, lhs, NO_INSERT))
            {
              gsi_replace (gsi, gimple_build_nop (), true);