r256417 - [OPENMP] Do not allow to use threadprivate or thread local variables as loop iteration variables.
Alexey Bataev via cfe-commits
cfe-commits at lists.llvm.org
Fri Dec 25 05:38:09 PST 2015
Author: abataev
Date: Fri Dec 25 07:38:08 2015
New Revision: 256417
URL: http://llvm.org/viewvc/llvm-project?rev=256417&view=rev
Log:
[OPENMP] Do not allow to use threadprivate or thread local variables as loop iteration variables.
According to OpenMP the loop iteration variable may not appear in a threadprivate directive.
Modified:
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/test/OpenMP/for_loop_messages.cpp
cfe/trunk/test/OpenMP/for_simd_loop_messages.cpp
cfe/trunk/test/OpenMP/parallel_for_loop_messages.cpp
cfe/trunk/test/OpenMP/parallel_for_simd_loop_messages.cpp
cfe/trunk/test/OpenMP/simd_loop_messages.cpp
cfe/trunk/test/OpenMP/taskloop_loop_messages.cpp
cfe/trunk/test/OpenMP/taskloop_simd_loop_messages.cpp
Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=256417&r1=256416&r2=256417&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Fri Dec 25 07:38:08 2015
@@ -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);
Modified: cfe/trunk/test/OpenMP/for_loop_messages.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/for_loop_messages.cpp?rev=256417&r1=256416&r2=256417&view=diff
==============================================================================
--- cfe/trunk/test/OpenMP/for_loop_messages.cpp (original)
+++ cfe/trunk/test/OpenMP/for_loop_messages.cpp Fri Dec 25 07:38:08 2015
@@ -10,6 +10,7 @@ public:
};
static int sii;
+// expected-note at +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 at +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];
Modified: cfe/trunk/test/OpenMP/for_simd_loop_messages.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/for_simd_loop_messages.cpp?rev=256417&r1=256416&r2=256417&view=diff
==============================================================================
--- cfe/trunk/test/OpenMP/for_simd_loop_messages.cpp (original)
+++ cfe/trunk/test/OpenMP/for_simd_loop_messages.cpp Fri Dec 25 07:38:08 2015
@@ -10,6 +10,7 @@ public:
};
static int sii;
+// expected-note at +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 at +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];
Modified: cfe/trunk/test/OpenMP/parallel_for_loop_messages.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/parallel_for_loop_messages.cpp?rev=256417&r1=256416&r2=256417&view=diff
==============================================================================
--- cfe/trunk/test/OpenMP/parallel_for_loop_messages.cpp (original)
+++ cfe/trunk/test/OpenMP/parallel_for_loop_messages.cpp Fri Dec 25 07:38:08 2015
@@ -10,6 +10,7 @@ public:
};
static int sii;
+// expected-note at +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 at +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];
Modified: cfe/trunk/test/OpenMP/parallel_for_simd_loop_messages.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/parallel_for_simd_loop_messages.cpp?rev=256417&r1=256416&r2=256417&view=diff
==============================================================================
--- cfe/trunk/test/OpenMP/parallel_for_simd_loop_messages.cpp (original)
+++ cfe/trunk/test/OpenMP/parallel_for_simd_loop_messages.cpp Fri Dec 25 07:38:08 2015
@@ -10,6 +10,7 @@ public:
};
static int sii;
+// expected-note at +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 at +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];
Modified: cfe/trunk/test/OpenMP/simd_loop_messages.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/simd_loop_messages.cpp?rev=256417&r1=256416&r2=256417&view=diff
==============================================================================
--- cfe/trunk/test/OpenMP/simd_loop_messages.cpp (original)
+++ cfe/trunk/test/OpenMP/simd_loop_messages.cpp Fri Dec 25 07:38:08 2015
@@ -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 at +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 at +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];
Modified: cfe/trunk/test/OpenMP/taskloop_loop_messages.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/taskloop_loop_messages.cpp?rev=256417&r1=256416&r2=256417&view=diff
==============================================================================
--- cfe/trunk/test/OpenMP/taskloop_loop_messages.cpp (original)
+++ cfe/trunk/test/OpenMP/taskloop_loop_messages.cpp Fri Dec 25 07:38:08 2015
@@ -10,6 +10,7 @@ public:
};
static int sii;
+// expected-note at +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 at +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];
Modified: cfe/trunk/test/OpenMP/taskloop_simd_loop_messages.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/taskloop_simd_loop_messages.cpp?rev=256417&r1=256416&r2=256417&view=diff
==============================================================================
--- cfe/trunk/test/OpenMP/taskloop_simd_loop_messages.cpp (original)
+++ cfe/trunk/test/OpenMP/taskloop_simd_loop_messages.cpp Fri Dec 25 07:38:08 2015
@@ -10,6 +10,7 @@ public:
};
static int sii;
+// expected-note at +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 at +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];
More information about the cfe-commits
mailing list