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.
This commit is contained in:
Tobias Burnus 2021-03-12 16:34:10 +01:00
parent 0b5437510c
commit d065576348
2 changed files with 16 additions and 5 deletions

View File

@ -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. */

View File

@ -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