public inbox for fortran@gcc.gnu.org
 help / color / mirror / Atom feed
* [Patch] Fortran/OpenMP: Accept implicit-save DATA vars for threadprivate [PR99514]
@ 2021-03-10 14:20 Tobias Burnus
  2021-03-12 12:07 ` Jakub Jelinek
  0 siblings, 1 reply; 2+ messages in thread
From: Tobias Burnus @ 2021-03-10 14:20 UTC (permalink / raw)
  To: gcc-patches, fortran, Jakub Jelinek

[-- Attachment #1: Type: text/plain, Size: 795 bytes --]

If a variable appears in DATA, the following applies:

F2018: 8.6.7  DATA statement
"Except for variables in named common blocks, a named variable has the
  SAVE attribute if any part of it is initialized in a DATA statement,
  and this may be confirmed by explicit specification."

The attached testcase was rejected as the implicit save was not honored.
There is no need to distinguish between SAVE and COMMON as common was/is
already accepted.

The code used only '&&' conditions without a '!' before the '('. Thus,
there is no need to indent half of the conditions ...

OK for mainline?

Tobias

-----------------
Mentor Graphics (Deutschland) GmbH, Arnulfstrasse 201, 80634 München Registergericht München HRB 106955, Geschäftsführer: Thomas Heurung, Frank Thürauf

[-- Attachment #2: omp-threadprivate.diff --]
[-- Type: text/x-patch, Size: 1892 bytes --]

Fortran/OpenMP: Accept implicit-save DATA vars for threadprivate [PR99514]

gcc/fortran/ChangeLog:

	PR fortran/99514
	* resolve.c (resolve_symbol): Accept vars which are in DATA
	and hence (either) implicit SAVE (or in common).

gcc/testsuite/ChangeLog:

	PR fortran/99514
	* gfortran.dg/gomp/threadprivate-1.f90: New test.

 gcc/fortran/resolve.c                              | 10 +++++-----
 gcc/testsuite/gfortran.dg/gomp/threadprivate-1.f90 | 11 +++++++++++
 2 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c
index 2a91ae743ea..32015c21efc 100644
--- a/gcc/fortran/resolve.c
+++ b/gcc/fortran/resolve.c
@@ -16024,12 +16024,12 @@ resolve_symbol (gfc_symbol *sym)
     }
 
   /* Check threadprivate restrictions.  */
-  if (sym->attr.threadprivate && !sym->attr.save
+  if (sym->attr.threadprivate
+      && !(sym->attr.save || sym->attr.data || sym->attr.in_common)
       && !(sym->ns->save_all && !sym->attr.automatic)
-      && (!sym->attr.in_common
-	  && sym->module == NULL
-	  && (sym->ns->proc_name == NULL
-	      || sym->ns->proc_name->attr.flavor != FL_MODULE)))
+      && sym->module == NULL
+      && (sym->ns->proc_name == NULL
+	  || sym->ns->proc_name->attr.flavor != FL_MODULE))
     gfc_error ("Threadprivate at %L isn't SAVEd", &sym->declared_at);
 
   /* Check omp declare target restrictions.  */
diff --git a/gcc/testsuite/gfortran.dg/gomp/threadprivate-1.f90 b/gcc/testsuite/gfortran.dg/gomp/threadprivate-1.f90
new file mode 100644
index 00000000000..59656c2b18d
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/gomp/threadprivate-1.f90
@@ -0,0 +1,11 @@
+! PR fortran/99514
+!
+! NTest in DATA is implicitly SAVE, unless in COMMON
+! Was failing before as the implicit SAVE was not
+! honoured by the threadprivate check.
+!
+
+program main
+  DATA NTest /1/
+  !$omp threadprivate(Ntest)
+end program main

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [Patch] Fortran/OpenMP: Accept implicit-save DATA vars for threadprivate [PR99514]
  2021-03-10 14:20 [Patch] Fortran/OpenMP: Accept implicit-save DATA vars for threadprivate [PR99514] Tobias Burnus
@ 2021-03-12 12:07 ` Jakub Jelinek
  0 siblings, 0 replies; 2+ messages in thread
From: Jakub Jelinek @ 2021-03-12 12:07 UTC (permalink / raw)
  To: Tobias Burnus; +Cc: gcc-patches, fortran

On Wed, Mar 10, 2021 at 03:20:51PM +0100, Tobias Burnus wrote:
> gcc/fortran/ChangeLog:
> 
> 	PR fortran/99514
> 	* resolve.c (resolve_symbol): Accept vars which are in DATA
> 	and hence (either) implicit SAVE (or in common).
> 
> gcc/testsuite/ChangeLog:
> 
> 	PR fortran/99514
> 	* gfortran.dg/gomp/threadprivate-1.f90: New test.

Ok, thanks.

	Jakub


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-03-12 12:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-10 14:20 [Patch] Fortran/OpenMP: Accept implicit-save DATA vars for threadprivate [PR99514] Tobias Burnus
2021-03-12 12:07 ` Jakub Jelinek

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).