Author: abataev Date: Tue Feb 9 03:41:09 2016 New Revision: 260213 URL: http://llvm.org/viewvc/llvm-project?rev=260213&view=rev Log: [OPENMP] Allow to reference threadprivate variable in same directive.
Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp cfe/trunk/test/OpenMP/threadprivate_messages.cpp Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=260213&r1=260212&r2=260213&view=diff ============================================================================== --- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original) +++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Tue Feb 9 03:41:09 2016 @@ -1179,8 +1179,10 @@ ExprResult Sema::ActOnOpenMPIdExpression } 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(SourceLo 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. Modified: cfe/trunk/test/OpenMP/threadprivate_messages.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/threadprivate_messages.cpp?rev=260213&r1=260212&r2=260213&view=diff ============================================================================== --- cfe/trunk/test/OpenMP/threadprivate_messages.cpp (original) +++ cfe/trunk/test/OpenMP/threadprivate_messages.cpp Tue Feb 9 03:41:09 2016 @@ -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) _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits