[OPENMP] Fixed messages about predetermined DSA for loop control variables.
authorAlexey Bataev <a.bataev@hotmail.com>
Wed, 6 May 2015 07:25:08 +0000 (07:25 +0000)
committerAlexey Bataev <a.bataev@hotmail.com>
Wed, 6 May 2015 07:25:08 +0000 (07:25 +0000)
llvm-svn: 236574

clang/lib/Sema/SemaOpenMP.cpp
clang/test/OpenMP/for_loop_messages.cpp

index 4877d3f..67fa678 100644 (file)
@@ -428,8 +428,13 @@ DSAStackTy::DSAVarData DSAStackTy::getTopDSA(VarDecl *D, bool FromParent) {
   if (D->getTLSKind() != VarDecl::TLS_None ||
       (D->getStorageClass() == SC_Register && D->hasAttr<AsmLabelAttr>() &&
        !D->isLocalVarDecl())) {
-    DVar.CKind = OMPC_threadprivate;
-    return DVar;
+    addDSA(D,
+           DeclRefExpr::Create(SemaRef.getASTContext(),
+                               NestedNameSpecifierLoc(), SourceLocation(), D,
+                               /*RefersToEnclosingVariableOrCapture=*/false,
+                               D->getLocation(),
+                               D->getType().getNonReferenceType(), VK_LValue),
+           OMPC_threadprivate);
   }
   if (Stack[0].SharingMap.count(D)) {
     DVar.RefExpr = Stack[0].SharingMap[D].RefExpr;
@@ -2573,7 +2578,9 @@ static bool CheckOpenMPIterationSpace(
     SemaRef.Diag(Init->getLocStart(), diag::err_omp_loop_var_dsa)
         << getOpenMPClauseName(DVar.CKind) << getOpenMPDirectiveName(DKind)
         << getOpenMPClauseName(PredeterminedCKind);
-    ReportOriginalDSA(SemaRef, &DSA, Var, DVar, true);
+    if (DVar.RefExpr == nullptr)
+      DVar.CKind = PredeterminedCKind;
+    ReportOriginalDSA(SemaRef, &DSA, Var, DVar, /*IsLoopIterVar=*/true);
     HasErrors = true;
   } else if (LoopVarRefExpr != nullptr) {
     // Make the loop iteration variable private (for worksharing constructs),
index 05b6430..39aaa5c 100644 (file)
@@ -13,7 +13,7 @@ static int sii;
 #pragma omp threadprivate(sii) // expected-note {{defined as threadprivate or thread local}}
 static int globalii;
 
-register int reg0 __asm__("0"); // expected-note {{loop iteration variable is predetermined as linear}}
+register int reg0 __asm__("0"); // expected-note {{defined as threadprivate or thread local}}
 
 int test_iteration_spaces() {
   const int N = 100;