This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[gomp] Fix threadprivate on module variables
- From: Jakub Jelinek <jakub at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org, fortran at gcc dot gnu dot org
- Date: Thu, 13 Oct 2005 07:58:12 -0400
- Subject: [gomp] Fix threadprivate on module variables
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
Hi!
I have committed following fix for threadprivate.
OpenMP standard says that module symbols as well as in_common symbols
don't need explicit SAVE, while other symbols mentioned in threadprivate
directive need it.
2005-10-13 Jakub Jelinek <jakub@redhat.com>
* resolve.c (resolve_symbol): Don't error if a threadprivate module
variable isn't SAVEd.
gcc/testsuite/
* gfortran.dg/gomp/omp_threadprivate2.f90: New test.
libgomp/
* testsuite/libgomp.fortran/threadprivate1.f90: New test.
--- gcc/fortran/resolve.c.jj 2005-10-10 11:30:07.000000000 +0200
+++ gcc/fortran/resolve.c 2005-10-13 12:41:31.000000000 +0200
@@ -4484,7 +4484,10 @@ resolve_symbol (gfc_symbol * sym)
/* Check threadprivate restrictions. */
if (sym->attr.threadprivate && !sym->attr.save
- && (!sym->attr.in_common || sym->module != NULL))
+ && (!sym->attr.in_common
+ && 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);
}
--- gcc/testsuite/gfortran.dg/gomp/omp_threadprivate2.f90.jj 2005-10-13 12:49:32.000000000 +0200
+++ gcc/testsuite/gfortran.dg/gomp/omp_threadprivate2.f90 2005-10-13 12:51:13.000000000 +0200
@@ -0,0 +1,5 @@
+! { dg-do compile }
+ subroutine bad1
+ double precision :: d ! { dg-error "isn't SAVEd" }
+!$omp threadprivate (d)
+ end subroutine bad1
--- libgomp/testsuite/libgomp.fortran/threadprivate1.f90.jj 2005-10-13 12:33:34.000000000 +0200
+++ libgomp/testsuite/libgomp.fortran/threadprivate1.f90 2005-10-13 12:33:49.000000000 +0200
@@ -0,0 +1,17 @@
+! { dg-do run }
+module threadprivate1
+ double precision :: d
+!$omp threadprivate (d)
+end module threadprivate1
+
+ use threadprivate1
+ integer omp_get_thread_num
+ logical :: l
+ l = .false.
+!$omp parallel num_threads (4) reduction (.or.:l)
+ d = omp_get_thread_num () + 6.5
+!$omp barrier
+ if (d .ne. omp_get_thread_num () + 6.5) l = .true.
+!$omp end parallel
+ if (l) call abort ()
+end
Jakub