aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobias Burnus <tobias@codesourcery.com>2021-03-08 13:05:48 +0100
committerTobias Burnus <tobias@codesourcery.com>2021-03-08 13:05:48 +0100
commit8a6a62614a8ae4544770420416d1632d6c3d3f6e (patch)
tree89857a0aa12104ba1977c92c1993b2c8cda23ef5
parente99b25df68d4528141f6079e1e3af8ef20bbcb00 (diff)
downloadgcc-8a6a62614a8ae4544770420416d1632d6c3d3f6e.zip
gcc-8a6a62614a8ae4544770420416d1632d6c3d3f6e.tar.gz
gcc-8a6a62614a8ae4544770420416d1632d6c3d3f6e.tar.bz2
tree-nested: Update assert for Fortran module vars [PR97927]
gcc/ChangeLog: PR fortran/97927 * tree-nested.c (convert_local_reference_stmt): Avoid calling lookup_field_for_decl for Fortran module (= namespace context). gcc/testsuite/ChangeLog: PR fortran/97927 * gfortran.dg/module_variable_3.f90: New test.
-rw-r--r--gcc/testsuite/gfortran.dg/module_variable_3.f9037
-rw-r--r--gcc/tree-nested.c1
2 files changed, 38 insertions, 0 deletions
diff --git a/gcc/testsuite/gfortran.dg/module_variable_3.f90 b/gcc/testsuite/gfortran.dg/module_variable_3.f90
new file mode 100644
index 0000000..0dae6d5
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/module_variable_3.f90
@@ -0,0 +1,37 @@
+! { dg-do compile }
+! { dg-additional-options "-fdump-tree-original" }
+!
+! PR fortran/97927
+!
+! Did ICE due to the in tree-nested.c due to {clobber}
+!
+
+module mpi2
+ interface
+ subroutine MPI_Allreduce(i)
+ implicit none
+ INTEGER, OPTIONAL, INTENT(OUT) :: i
+ end subroutine MPI_Allreduce
+ end interface
+end module
+
+module modmpi
+ implicit none
+ integer ierror ! module variable = context NAMESPACE_DECL
+end module
+
+subroutine exxengy
+ use modmpi
+ use mpi2, only: mpi_allreduce
+ implicit none
+
+ ! intent(out) implies: ierror = {clobber}
+ call mpi_allreduce(ierror)
+
+contains
+ subroutine zrho2
+ return
+ end subroutine
+end subroutine
+
+! { dg-final { scan-tree-dump "ierror = {CLOBBER};" "original" } }
diff --git a/gcc/tree-nested.c b/gcc/tree-nested.c
index addd6ee..cea917a 100644
--- a/gcc/tree-nested.c
+++ b/gcc/tree-nested.c
@@ -2526,6 +2526,7 @@ convert_local_reference_stmt (gimple_stmt_iterator *gsi, bool *handled_ops_p,
{
tree lhs = gimple_assign_lhs (stmt);
if (DECL_P (lhs)
+ && decl_function_context (lhs) == info->context
&& !use_pointer_in_frame (lhs)
&& lookup_field_for_decl (info, lhs, NO_INSERT))
{