re PR fortran/88304 (ICE in use_pointer_in_frame, at tree-nested.c:267)
authorJakub Jelinek <jakub@redhat.com>
Thu, 6 Dec 2018 10:28:31 +0000 (11:28 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Thu, 6 Dec 2018 10:28:31 +0000 (11:28 +0100)
PR fortran/88304
* tree-nested.c (convert_nonlocal_reference_stmt): Remove clobbers
for non-local automatic decls.

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

From-SVN: r266847

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

index 216f6eec668d48925454e246ac9d35432cdb6a36..b60efcf4821fa54aa13a759b9dae0f9fee0af254 100644 (file)
@@ -1,3 +1,9 @@
+2018-12-06  Jakub Jelinek  <jakub@redhat.com>
+
+       PR fortran/88304
+       * tree-nested.c (convert_nonlocal_reference_stmt): Remove clobbers
+       for non-local automatic decls.
+
 2018-12-05  David Edelsohn  <dje.gcc@gmail.com>
 
        * config/rs6000/aix72.h (ASM_DEFAULT_SPEC): Match Power7 processor
index 76c44a6ffba1c50fbda21b8bccd1244c613287a5..bc5bf6720ecc51d028300a6ef48ee511b210a992 100644 (file)
@@ -1,3 +1,8 @@
+2018-12-06  Jakub Jelinek  <jakub@redhat.com>
+
+       PR fortran/88304
+       * gfortran.fortran-torture/compile/pr88304.f90: New test.
+
 2018-12-06  Richard Biener  <rguenther@suse.de>
 
        PR middle-end/63184
diff --git a/gcc/testsuite/gfortran.fortran-torture/compile/pr88304.f90 b/gcc/testsuite/gfortran.fortran-torture/compile/pr88304.f90
new file mode 100644 (file)
index 0000000..fb69b8c
--- /dev/null
@@ -0,0 +1,24 @@
+! PR fortran/88304
+
+module pr88304
+  implicit none
+  type t
+     integer :: b = -1
+  end type t
+contains
+  subroutine f1 (x, y)
+    integer, intent(out) :: x, y
+    x = 5
+    y = 6
+  end subroutine f1
+  subroutine f2 ()
+    type(t) :: x
+    integer :: y
+    call f3
+    if (x%b .ne. 5 .or. y .ne. 6) stop 1
+  contains
+    subroutine f3
+      call f1 (x%b, y)
+    end subroutine f3
+  end subroutine f2
+end module pr88304
index 3ab60a780154046c3d6f8788aae835b442b11b55..ea54246657449be315a07450734c62914d67ebe2 100644 (file)
@@ -1648,6 +1648,21 @@ convert_nonlocal_reference_stmt (gimple_stmt_iterator *gsi, bool *handled_ops_p,
       *handled_ops_p = false;
       return NULL_TREE;
 
+    case GIMPLE_ASSIGN:
+      if (gimple_clobber_p (stmt))
+       {
+         tree lhs = gimple_assign_lhs (stmt);
+         if (DECL_P (lhs)
+             && !(TREE_STATIC (lhs) || DECL_EXTERNAL (lhs))
+             && decl_function_context (lhs) != info->context)
+           {
+             gsi_replace (gsi, gimple_build_nop (), true);
+             break;
+           }
+       }
+      *handled_ops_p = false;
+      return NULL_TREE;
+
     default:
       /* For every other statement that we are not interested in
         handling here, let the walker traverse the operands.  */