diff mbox series

Fix tree-nested convert_local_* clobber handling (PR fortran/88304)

Message ID 20181208091022.GT12380@tucnak
State New
Headers show
Series Fix tree-nested convert_local_* clobber handling (PR fortran/88304) | expand

Commit Message

Jakub Jelinek Dec. 8, 2018, 9:10 a.m. UTC
Hi!

Unlike convert_nonlocal_reference_stmt, convert_local_reference_stmt already
had the clobber handling code, but apparently written in times where only
decls were allowed on the lhs and not adjusted when we started allowing
MEM_REFs in there.  use_pointer_in_frame certainly ICEs if it is called with
non-decl and there is no need to adjust the MEM_REF lhs clobbers.

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

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.

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


	Jakub

Comments

Richard Biener Dec. 8, 2018, 1:31 p.m. UTC | #1
On December 8, 2018 10:10:22 AM GMT+01:00, Jakub Jelinek <jakub@redhat.com> wrote:
>Hi!
>
>Unlike convert_nonlocal_reference_stmt, convert_local_reference_stmt
>already
>had the clobber handling code, but apparently written in times where
>only
>decls were allowed on the lhs and not adjusted when we started allowing
>MEM_REFs in there.  use_pointer_in_frame certainly ICEs if it is called
>with
>non-decl and there is no need to adjust the MEM_REF lhs clobbers.
>
>Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

OK. 

Richard. 

>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.
>
>	* gfortran.fortran-torture/compile/pr88304-2.f90: New test.
>
>--- gcc/tree-nested.c.jj	2018-12-06 11:24:39.449782464 +0100
>+++ gcc/tree-nested.c	2018-12-07 11:57:58.229967581 +0100
>@@ -2324,7 +2324,8 @@ convert_local_reference_stmt (gimple_stm
>       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);
>---
>gcc/testsuite/gfortran.fortran-torture/compile/pr88304-2.f90.jj	2018-12-07
>12:01:07.619899707 +0100
>+++
>gcc/testsuite/gfortran.fortran-torture/compile/pr88304-2.f90	2018-12-07
>12:00:51.808155756 +0100
>@@ -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
>
>	Jakub
diff mbox series

Patch

--- gcc/tree-nested.c.jj	2018-12-06 11:24:39.449782464 +0100
+++ gcc/tree-nested.c	2018-12-07 11:57:58.229967581 +0100
@@ -2324,7 +2324,8 @@  convert_local_reference_stmt (gimple_stm
       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);
--- gcc/testsuite/gfortran.fortran-torture/compile/pr88304-2.f90.jj	2018-12-07 12:01:07.619899707 +0100
+++ gcc/testsuite/gfortran.fortran-torture/compile/pr88304-2.f90	2018-12-07 12:00:51.808155756 +0100
@@ -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