]> granicus.if.org Git - clang/commitdiff
[OPENMP] Do not allow to use threadprivate or thread local variables as loop iteratio...
authorAlexey Bataev <a.bataev@hotmail.com>
Fri, 25 Dec 2015 13:38:08 +0000 (13:38 +0000)
committerAlexey Bataev <a.bataev@hotmail.com>
Fri, 25 Dec 2015 13:38:08 +0000 (13:38 +0000)
According to OpenMP the loop iteration variable may not appear in a threadprivate directive.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@256417 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
test/OpenMP/taskloop_loop_messages.cpp
test/OpenMP/taskloop_simd_loop_messages.cpp

index dea301602ebbe03d4d69523678763830d0ebb9b4..c42718d576bc831b1de592e1b3b46c4eeb327241 100644 (file)
@@ -3494,14 +3494,12 @@ static bool CheckOpenMPIterationSpace(
           ? ((NestedLoopCount == 1) ? OMPC_linear : OMPC_lastprivate)
           : OMPC_private;
   if (((isOpenMPSimdDirective(DKind) && DVar.CKind != OMPC_unknown &&
-        DVar.CKind != OMPC_threadprivate && DVar.CKind != PredeterminedCKind) ||
+        DVar.CKind != PredeterminedCKind) ||
        ((isOpenMPWorksharingDirective(DKind) || DKind == OMPD_taskloop ||
-        isOpenMPDistributeDirective(DKind)) &&
+         isOpenMPDistributeDirective(DKind)) &&
         !isOpenMPSimdDirective(DKind) && DVar.CKind != OMPC_unknown &&
-        DVar.CKind != OMPC_private && DVar.CKind != OMPC_lastprivate &&
-        DVar.CKind != OMPC_threadprivate)) &&
-      ((DVar.CKind != OMPC_private && DVar.CKind != OMPC_threadprivate) ||
-       DVar.RefExpr != nullptr)) {
+        DVar.CKind != OMPC_private && DVar.CKind != OMPC_lastprivate)) &&
+      (DVar.CKind != OMPC_private || DVar.RefExpr != nullptr)) {
     SemaRef.Diag(Init->getLocStart(), diag::err_omp_loop_var_dsa)
         << getOpenMPClauseName(DVar.CKind) << getOpenMPDirectiveName(DKind)
         << getOpenMPClauseName(PredeterminedCKind);
index 7f0b11410102974d44928a4fad5f39b9e16f9bc7..895baf57e9ccc40554f3588993346dfb1931aa11 100644 (file)
@@ -10,6 +10,7 @@ public:
 };
 
 static int sii;
+// expected-note@+1 {{defined as threadprivate or thread local}}
 #pragma omp threadprivate(sii)
 static int globalii;
 
@@ -309,6 +310,7 @@ 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];
index d336888d2bc13d313eeea629930573497c447c31..958c7f60d0eb58d116143d655d52022100c7524f 100644 (file)
@@ -10,6 +10,7 @@ public:
 };
 
 static int sii;
+// expected-note@+1 {{defined as threadprivate or thread local}}
 #pragma omp threadprivate(sii)
 static int globalii;
 
@@ -306,6 +307,7 @@ 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 2a65d781a072cf2e630af0d3981abe49a26b6e5f..2bb32bdfc17688fdbafd56df3877a0b7b3df6578 100644 (file)
@@ -10,6 +10,7 @@ public:
 };
 
 static int sii;
+// expected-note@+1 {{defined as threadprivate or thread local}}
 #pragma omp threadprivate(sii)
 static int globalii;
 
@@ -257,6 +258,7 @@ 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 8fe58434bc5a59f7f9b4ed6206900ea487200c29..f4929d97d48499841e63f1aefbf4a88cf8cc8ca1 100644 (file)
@@ -10,6 +10,7 @@ public:
 };
 
 static int sii;
+// expected-note@+1 {{defined as threadprivate or thread local}}
 #pragma omp threadprivate(sii)
 static int globalii;
 
@@ -259,6 +260,7 @@ 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 677f2b9a2e48f51b417ffd58967e59dd71586652..96b4cafc6bd88a95fea30a1e18f14828754415dc 100644 (file)
@@ -1,6 +1,7 @@
 // RUN: %clang_cc1 -fsyntax-only -fopenmp -x c++ -std=c++11 -fexceptions -fcxx-exceptions -verify %s
 
 static int sii;
+// expected-note@+1 {{defined as threadprivate or thread local}}
 #pragma omp threadprivate(sii)
 static int globalii;
 
@@ -252,6 +253,7 @@ 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];
index 3ff8005f7fe1b3066543236541d09de463012c92..02518e572f3af7ffbc2937d94576d46ac5f1ba3d 100644 (file)
@@ -10,6 +10,7 @@ public:
 };
 
 static int sii;
+// expected-note@+1 {{defined as threadprivate or thread local}}
 #pragma omp threadprivate(sii)
 static int globalii;
 
@@ -310,6 +311,7 @@ int test_iteration_spaces() {
 
 #pragma omp parallel
   {
+// expected-error@+2 {{loop iteration variable in the associated loop of 'omp taskloop' directive may not be threadprivate or thread local, predetermined as private}}
 #pragma omp taskloop
     for (sii = 0; sii < 10; sii += 1)
       c[sii] = a[sii];
index 34da10b712e7cbc5d9da54f0336bb8240275adf2..47318721102fd9221e9f7a59b87aa0626cd25541 100644 (file)
@@ -10,6 +10,7 @@ public:
 };
 
 static int sii;
+// expected-note@+1 {{defined as threadprivate or thread local}}
 #pragma omp threadprivate(sii)
 static int globalii;
 
@@ -311,6 +312,7 @@ int test_iteration_spaces() {
 
 #pragma omp parallel
   {
+// expected-error@+2 {{loop iteration variable in the associated loop of 'omp taskloop simd' directive may not be threadprivate or thread local, predetermined as linear}}
 #pragma omp taskloop simd
     for (sii = 0; sii < 10; sii += 1)
       c[sii] = a[sii];