public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Handle clobber stmts in convert_nonlocal_reference_stmt (PR fortran/88304)
@ 2018-12-06  6:25 Jakub Jelinek
  2018-12-06  8:49 ` Richard Biener
  0 siblings, 1 reply; 2+ messages in thread
From: Jakub Jelinek @ 2018-12-06  6:25 UTC (permalink / raw)
  To: Richard Biener; +Cc: gcc-patches

Hi!

The following patch handles clobber stmts the same how we handle them in
convert_local_reference_stmt, if it is the clobber with decl on the lhs and
that lhs needs to be replaced by a field inside of a structure, the clobber
is replaced by GIMPLE_NOP.

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

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.

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

--- gcc/tree-nested.c.jj	2018-12-02 13:50:20.186440444 +0100
+++ gcc/tree-nested.c	2018-12-05 11:28:54.979178773 +0100
@@ -1648,6 +1648,21 @@ convert_nonlocal_reference_stmt (gimple_
       *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.  */
--- gcc/testsuite/gfortran.fortran-torture/compile/pr88304.f90.jj	2018-12-05 11:31:04.232046102 +0100
+++ gcc/testsuite/gfortran.fortran-torture/compile/pr88304.f90	2018-12-05 11:30:57.092163910 +0100
@@ -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

	Jakub

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-12-06  8:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-06  6:25 [PATCH] Handle clobber stmts in convert_nonlocal_reference_stmt (PR fortran/88304) Jakub Jelinek
2018-12-06  8:49 ` Richard Biener

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).