public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-805] Fortran/OpenMP: Handle implicit SAVE for variables in main
@ 2021-05-14 17:20 Tobias Burnus
0 siblings, 0 replies; only message in thread
From: Tobias Burnus @ 2021-05-14 17:20 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:62e1bd651f60cfe3daaad91b41b7612bc7fa7460
commit r12-805-g62e1bd651f60cfe3daaad91b41b7612bc7fa7460
Author: Tobias Burnus <tobias@codesourcery.com>
Date: Fri May 14 19:19:26 2021 +0200
Fortran/OpenMP: Handle implicit SAVE for variables in main
gcc/fortran/ChangeLog:
* resolve.c (resolve_symbol): Handle implicit SAVE of main-program
for vars in 'omp threadprivate' and 'omp declare target'.
gcc/testsuite/ChangeLog:
* gfortran.dg/gomp/implicit-save.f90: New test.
Diff:
---
gcc/fortran/resolve.c | 6 ++++--
gcc/testsuite/gfortran.dg/gomp/implicit-save.f90 | 11 +++++++++++
2 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c
index 5a81387e277..83b41a349b6 100644
--- a/gcc/fortran/resolve.c
+++ b/gcc/fortran/resolve.c
@@ -16039,7 +16039,8 @@ resolve_symbol (gfc_symbol *sym)
&& !(sym->ns->save_all && !sym->attr.automatic)
&& sym->module == NULL
&& (sym->ns->proc_name == NULL
- || sym->ns->proc_name->attr.flavor != FL_MODULE))
+ || (sym->ns->proc_name->attr.flavor != FL_MODULE
+ && !sym->ns->proc_name->attr.is_main_program)))
gfc_error ("Threadprivate at %L isn't SAVEd", &sym->declared_at);
/* Check omp declare target restrictions. */
@@ -16050,7 +16051,8 @@ resolve_symbol (gfc_symbol *sym)
&& (!sym->attr.in_common
&& sym->module == NULL
&& (sym->ns->proc_name == NULL
- || sym->ns->proc_name->attr.flavor != FL_MODULE)))
+ || (sym->ns->proc_name->attr.flavor != FL_MODULE
+ && !sym->ns->proc_name->attr.is_main_program))))
gfc_error ("!$OMP DECLARE TARGET variable %qs at %L isn't SAVEd",
sym->name, &sym->declared_at);
diff --git a/gcc/testsuite/gfortran.dg/gomp/implicit-save.f90 b/gcc/testsuite/gfortran.dg/gomp/implicit-save.f90
new file mode 100644
index 00000000000..2af9647490e
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/gomp/implicit-save.f90
@@ -0,0 +1,11 @@
+subroutine foo
+ integer :: n = 5, m = 7
+ !$omp declare target to(n)
+ !$omp threadprivate (m)
+end
+
+program main
+ integer :: i, j
+ !$omp declare target to(i)
+ !$omp threadprivate (j)
+end
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-05-14 17:20 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-14 17:20 [gcc r12-805] Fortran/OpenMP: Handle implicit SAVE for variables in main Tobias Burnus
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).