On Thu, 6 Dec 2018, Jakub Jelinek wrote:

> 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?

OK.

Richard.

> 2018-12-06  Jakub Jelinek  <ja...@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
> 
> 

-- 
Richard Biener <rguent...@suse.de>
SUSE LINUX GmbH, GF: Felix Imendoerffer, Jane Smithard, Graham Norton, HRB 
21284 (AG Nuernberg)

Reply via email to