diff options
author | Andre Vehreschild <vehre@gcc.gnu.org> | 2024-07-22 15:31:37 +0200 |
---|---|---|
committer | Andre Vehreschild <vehre@gcc.gnu.org> | 2024-08-12 10:44:35 +0200 |
commit | 8d8db21eb726b785782f4a41ad85a0d4be63068a (patch) | |
tree | cb804faa49bfeffa9cf0e436d825a66ae3c259a6 | |
parent | 4bcb480d103b36c389daaf711f0f25d74379adb6 (diff) | |
download | gcc-8d8db21eb726b785782f4a41ad85a0d4be63068a.zip gcc-8d8db21eb726b785782f4a41ad85a0d4be63068a.tar.gz gcc-8d8db21eb726b785782f4a41ad85a0d4be63068a.tar.bz2 |
Fortran: Fix coarray in associate not linking [PR85510]
PR fortran/85510
gcc/fortran/ChangeLog:
* resolve.cc (resolve_variable): Mark the variable as host
associated only, when it is not in an associate block.
* trans-decl.cc (generate_coarray_init): Remove incorrect unused
flag on parameter.
gcc/testsuite/ChangeLog:
* gfortran.dg/coarray/pr85510.f90: New test.
-rw-r--r-- | gcc/fortran/resolve.cc | 10 | ||||
-rw-r--r-- | gcc/fortran/trans-decl.cc | 2 | ||||
-rw-r--r-- | gcc/testsuite/gfortran.dg/coarray/pr85510.f90 | 19 |
3 files changed, 26 insertions, 5 deletions
diff --git a/gcc/fortran/resolve.cc b/gcc/fortran/resolve.cc index eb3085a..8e88aac 100644 --- a/gcc/fortran/resolve.cc +++ b/gcc/fortran/resolve.cc @@ -6114,10 +6114,12 @@ resolve_variable (gfc_expr *e) /* If a symbol has been host_associated mark it. This is used latter, to identify if aliasing is possible via host association. */ if (sym->attr.flavor == FL_VARIABLE - && gfc_current_ns->parent - && (gfc_current_ns->parent == sym->ns - || (gfc_current_ns->parent->parent - && gfc_current_ns->parent->parent == sym->ns))) + && (!sym->ns->code || sym->ns->code->op != EXEC_BLOCK + || !sym->ns->code->ext.block.assoc) + && gfc_current_ns->parent + && (gfc_current_ns->parent == sym->ns + || (gfc_current_ns->parent->parent + && gfc_current_ns->parent->parent == sym->ns))) sym->attr.host_assoc = 1; if (gfc_current_ns->proc_name diff --git a/gcc/fortran/trans-decl.cc b/gcc/fortran/trans-decl.cc index ca6a515..6692ac7 100644 --- a/gcc/fortran/trans-decl.cc +++ b/gcc/fortran/trans-decl.cc @@ -5950,7 +5950,7 @@ generate_coarray_sym_init (gfc_symbol *sym) coarrays. */ static void -generate_coarray_init (gfc_namespace * ns __attribute((unused))) +generate_coarray_init (gfc_namespace *ns) { tree fndecl, tmp, decl, save_fn_decl; diff --git a/gcc/testsuite/gfortran.dg/coarray/pr85510.f90 b/gcc/testsuite/gfortran.dg/coarray/pr85510.f90 new file mode 100644 index 0000000..c6777ca --- /dev/null +++ b/gcc/testsuite/gfortran.dg/coarray/pr85510.f90 @@ -0,0 +1,19 @@ +!{ dg-do run } + +! Contributed by Damian Rouson <damian@archaeologic.codes> +! Check that PR fortran/85510 links. + +module foo +contains + subroutine bar() + integer, save :: i[*] = 1 + associate(n=>1) + if (i[1] /= 1) stop 1 + end associate + end subroutine +end module + +use foo +call bar() +end + |