]> granicus.if.org Git - clang/commitdiff
[OPENMP] Allow using of threadprivate variables as loop-control variables in lop...
authorAlexey Bataev <a.bataev@hotmail.com>
Tue, 12 May 2015 09:02:07 +0000 (09:02 +0000)
committerAlexey Bataev <a.bataev@hotmail.com>
Tue, 12 May 2015 09:02:07 +0000 (09:02 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@237102 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaOpenMP.cpp
test/OpenMP/for_loop_messages.cpp
test/OpenMP/for_simd_loop_messages.cpp
test/OpenMP/parallel_for_loop_messages.cpp
test/OpenMP/parallel_for_simd_loop_messages.cpp
test/OpenMP/simd_loop_messages.cpp

index db238c02d5cc8a11473a1f13059e796a65b3c32f..dd3ff37c37baaa6b57c4d8021f76ad88bcb3b96b 100644 (file)
@@ -2606,11 +2606,12 @@ static bool CheckOpenMPIterationSpace(
           ? ((NestedLoopCount == 1) ? OMPC_linear : OMPC_lastprivate)
           : OMPC_private;
   if (((isOpenMPSimdDirective(DKind) && DVar.CKind != OMPC_unknown &&
-        DVar.CKind != PredeterminedCKind) ||
+        DVar.CKind != OMPC_threadprivate && DVar.CKind != PredeterminedCKind) ||
        (isOpenMPWorksharingDirective(DKind) && !isOpenMPSimdDirective(DKind) &&
         DVar.CKind != OMPC_unknown && DVar.CKind != OMPC_private &&
-        DVar.CKind != OMPC_lastprivate)) &&
-      (DVar.CKind != OMPC_private || DVar.RefExpr != nullptr)) {
+        DVar.CKind != OMPC_lastprivate && DVar.CKind != OMPC_threadprivate)) &&
+      ((DVar.CKind != OMPC_private && DVar.CKind != OMPC_threadprivate) ||
+       DVar.RefExpr != nullptr)) {
     SemaRef.Diag(Init->getLocStart(), diag::err_omp_loop_var_dsa)
         << getOpenMPClauseName(DVar.CKind) << getOpenMPDirectiveName(DKind)
         << getOpenMPClauseName(PredeterminedCKind);
index 39aaa5cf28b9e5c4679e4ed01350f78fa96db6dc..86220648a857686eb6a2daae4f91a3e686b7f239 100644 (file)
@@ -10,10 +10,10 @@ public:
 };
 
 static int sii;
-#pragma omp threadprivate(sii) // expected-note {{defined as threadprivate or thread local}}
+#pragma omp threadprivate(sii)
 static int globalii;
 
-register int reg0 __asm__("0"); // expected-note {{defined as threadprivate or thread local}}
+register int reg0 __asm__("0");
 
 int test_iteration_spaces() {
   const int N = 100;
@@ -308,7 +308,6 @@ int test_iteration_spaces() {
 
 #pragma omp parallel
   {
-// expected-error@+2 {{loop iteration variable in the associated loop of 'omp for' directive may not be threadprivate or thread local, predetermined as private}}
 #pragma omp for
     for (sii = 0; sii < 10; sii += 1)
       c[sii] = a[sii];
@@ -316,7 +315,6 @@ int test_iteration_spaces() {
 
 #pragma omp parallel
   {
-// expected-error@+2 {{loop iteration variable in the associated loop of 'omp for' directive may not be threadprivate or thread local, predetermined as private}}
 #pragma omp for
     for (reg0 = 0; reg0 < 10; reg0 += 1)
       c[reg0] = a[reg0];
index db59d9d22ee7d6e559167cb7783a79b2047bff61..15dbefe793de3aad10b857c9020da5a80c069668 100644 (file)
@@ -10,7 +10,7 @@ public:
 };
 
 static int sii;
-#pragma omp threadprivate(sii) // expected-note {{defined as threadprivate or thread local}}
+#pragma omp threadprivate(sii)
 static int globalii;
 
 int test_iteration_spaces() {
@@ -306,7 +306,6 @@ int test_iteration_spaces() {
 
 #pragma omp parallel
   {
-// expected-error@+2 {{loop iteration variable in the associated loop of 'omp for simd' directive may not be threadprivate or thread local, predetermined as linear}}
 #pragma omp for simd
     for (sii = 0; sii < 10; sii += 1)
       c[sii] = a[sii];
index 318f0e6d9ec0087224808f38cf241318bb9348e0..ba54c6a5ecfd6a843c7bfab70467f96b83e3d80b 100644 (file)
@@ -10,7 +10,7 @@ public:
 };
 
 static int sii;
-#pragma omp threadprivate(sii) // expected-note {{defined as threadprivate or thread local}}
+#pragma omp threadprivate(sii)
 static int globalii;
 
 int test_iteration_spaces() {
@@ -258,7 +258,6 @@ int test_iteration_spaces() {
     c[ii] = a[ii];
 
   {
-// expected-error@+2 {{loop iteration variable in the associated loop of 'omp parallel for' directive may not be threadprivate or thread local, predetermined as private}}
 #pragma omp parallel for
     for (sii = 0; sii < 10; sii += 1)
       c[sii] = a[sii];
index 43dbbe089bbf5340cfae2a574e5beb687de460af..b182f1b6978ba96e724d4becba5d699386ceb131 100644 (file)
@@ -10,7 +10,7 @@ public:
 };
 
 static int sii;
-#pragma omp threadprivate(sii) // expected-note {{defined as threadprivate or thread local}}
+#pragma omp threadprivate(sii)
 static int globalii;
 
 int test_iteration_spaces() {
@@ -259,7 +259,6 @@ int test_iteration_spaces() {
     c[ii] = a[ii];
 
   {
-// expected-error@+2 {{loop iteration variable in the associated loop of 'omp parallel for simd' directive may not be threadprivate or thread local, predetermined as linear}}
 #pragma omp parallel for simd
     for (sii = 0; sii < 10; sii += 1)
       c[sii] = a[sii];
index b2c804c93e5b99cf9b58232d358fc88e8b0b5e84..b3d0a3073677292aa039e681d15c4300403e5053 100644 (file)
@@ -1,7 +1,7 @@
 // RUN: %clang_cc1 -fsyntax-only -fopenmp=libiomp5 -x c++ -std=c++11 -fexceptions -fcxx-exceptions -verify %s
 
 static int sii;
-#pragma omp threadprivate(sii) // expected-note {{defined as threadprivate or thread local}}
+#pragma omp threadprivate(sii)
 static int globalii;
 
 int test_iteration_spaces() {
@@ -252,7 +252,6 @@ int test_iteration_spaces() {
 
   #pragma omp parallel
   {
-    // expected-error@+2 {{loop iteration variable in the associated loop of 'omp simd' directive may not be threadprivate or thread local, predetermined as linear}}
     #pragma omp simd
     for (sii = 0; sii < 10; sii+=1)
       c[sii] = a[sii];