]> granicus.if.org Git - clang/commitdiff
[OPENMP]Fix checks for DSA in simd constructs.
authorAlexey Bataev <a.bataev@hotmail.com>
Fri, 28 Jun 2019 14:59:25 +0000 (14:59 +0000)
committerAlexey Bataev <a.bataev@hotmail.com>
Fri, 28 Jun 2019 14:59:25 +0000 (14:59 +0000)
The errors for incorrectly specified data-sharing attributes for simd
constructs must be emitted only for the explicitly provided clauses, not
the predetermined ones.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@364647 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaOpenMP.cpp
test/OpenMP/simd_loop_messages.cpp

index b531d31c1ca90d5fb5f828810ff9f66d2cd5533f..732b22cbf30b6252ccee91377fb24a9c3a130a8e 100644 (file)
@@ -5697,12 +5697,12 @@ static bool checkOpenMPIterationSpace(
             ? ((NestedLoopCount == 1) ? OMPC_linear : OMPC_lastprivate)
             : OMPC_private;
     if (((isOpenMPSimdDirective(DKind) && DVar.CKind != OMPC_unknown &&
-          DVar.CKind != PredeterminedCKind) ||
+          DVar.CKind != PredeterminedCKind && DVar.RefExpr) ||
          ((isOpenMPWorksharingDirective(DKind) || DKind == OMPD_taskloop ||
            isOpenMPDistributeDirective(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_private || DVar.RefExpr)) {
       SemaRef.Diag(Init->getBeginLoc(), diag::err_omp_loop_var_dsa)
           << getOpenMPClauseName(DVar.CKind) << getOpenMPDirectiveName(DKind)
           << getOpenMPClauseName(PredeterminedCKind);
index 80f3cb14b76e59a0404bf8be71d57e19a29ecc25..4c4ce5f98c260893269b87554b00521fa7ff74bc 100644 (file)
@@ -1,5 +1,4 @@
 // RUN: %clang_cc1 -fsyntax-only -fopenmp -x c++ -std=c++11 -fexceptions -fcxx-exceptions -verify %s
-
 // RUN: %clang_cc1 -fsyntax-only -fopenmp-simd -x c++ -std=c++11 -fexceptions -fcxx-exceptions -verify %s
 
 static int sii;
@@ -7,12 +6,22 @@ static int sii;
 #pragma omp threadprivate(sii)
 static int globalii;
 
+struct S {
+  static int ssi;
+};
+
 int test_iteration_spaces() {
   const int N = 100;
   float a[N], b[N], c[N];
   int ii, jj, kk;
   float fii;
   double dii;
+#pragma omp simd linear(S::ssi)
+  for (S::ssi = 0; S::ssi < 10; ++S::ssi)
+    ;
+#pragma omp simd // no messages expected
+  for (S::ssi = 0; S::ssi < 10; ++S::ssi)
+    ;
   #pragma omp simd
   for (int i = 0; i < 10; i+=1) {
     c[i] = a[i] + b[i];