From: jakub Date: Thu, 6 Dec 2018 10:28:31 +0000 (+0000) Subject: PR fortran/88304 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=39bb2d0f4f6a3700ec09652f2601a366af09fef1;p=thirdparty%2Fgcc.git 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@266847 138bc75d-0d04-0410-961f-82ee72b054a4 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 216f6eec668d..b60efcf4821f 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2018-12-06 Jakub Jelinek + + PR fortran/88304 + * tree-nested.c (convert_nonlocal_reference_stmt): Remove clobbers + for non-local automatic decls. + 2018-12-05 David Edelsohn * config/rs6000/aix72.h (ASM_DEFAULT_SPEC): Match Power7 processor diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 76c44a6ffba1..bc5bf6720ecc 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-12-06 Jakub Jelinek + + PR fortran/88304 + * gfortran.fortran-torture/compile/pr88304.f90: New test. + 2018-12-06 Richard Biener 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 index 000000000000..fb69b8c9918e --- /dev/null +++ b/gcc/testsuite/gfortran.fortran-torture/compile/pr88304.f90 @@ -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 diff --git a/gcc/tree-nested.c b/gcc/tree-nested.c index 3ab60a780154..ea5424665744 100644 --- a/gcc/tree-nested.c +++ b/gcc/tree-nested.c @@ -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. */