]> granicus.if.org Git - clang/commitdiff
[OPENMP] Allow to reference threadprivate variable in same directive.
authorAlexey Bataev <a.bataev@hotmail.com>
Tue, 9 Feb 2016 09:41:09 +0000 (09:41 +0000)
committerAlexey Bataev <a.bataev@hotmail.com>
Tue, 9 Feb 2016 09:41:09 +0000 (09:41 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@260213 91177308-0d34-0410-b5e6-96231b3b80d8

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

index d4c1f98c99897cb2da547954a6cd1bdeccdc8b42..3ba5daa03042f246562acf320e6335e99bef252c 100644 (file)
@@ -1179,8 +1179,10 @@ ExprResult Sema::ActOnOpenMPIdExpression(Scope *CurScope,
   }
 
   QualType ExprType = VD->getType().getNonReferenceType();
-  ExprResult DE = buildDeclRefExpr(*this, VD, ExprType, Id.getLoc());
-  return DE;
+  return DeclRefExpr::Create(Context, NestedNameSpecifierLoc(),
+                             SourceLocation(), VD,
+                             /*RefersToEnclosingVariableOrCapture=*/false,
+                             Id.getLoc(), ExprType, VK_LValue);
 }
 
 Sema::DeclGroupPtrTy
@@ -1230,6 +1232,10 @@ Sema::CheckOMPThreadPrivateDecl(SourceLocation Loc, ArrayRef<Expr *> VarList) {
     VarDecl *VD = cast<VarDecl>(DE->getDecl());
     SourceLocation ILoc = DE->getExprLoc();
 
+    // Mark variable as used.
+    VD->setReferenced();
+    VD->markUsed(Context);
+
     QualType QType = VD->getType();
     if (QType->isDependentType() || QType->isInstantiationDependentType()) {
       // It will be analyzed later.
index 8c442f47ad5eedfee8bc087ba29942d2a1987a81..9775bfa458f49101f9e79a262210287327aa49da 100644 (file)
@@ -70,7 +70,7 @@ class TestClass {
 
 namespace ns {
   int m;
-#pragma omp threadprivate (m)
+#pragma omp threadprivate (m, m)
 }
 #pragma omp threadprivate (m) // expected-error {{use of undeclared identifier 'm'}}
 #pragma omp threadprivate (ns::m)