public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Tobias Burnus <burnus@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r12-805] Fortran/OpenMP: Handle implicit SAVE for variables in main Date: Fri, 14 May 2021 17:20:05 +0000 (GMT) [thread overview] Message-ID: <20210514172005.B178A386FC11@sourceware.org> (raw) 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
reply other threads:[~2021-05-14 17:20 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20210514172005.B178A386FC11@sourceware.org \ --to=burnus@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).