From: Alexey Bataev Date: Fri, 7 Mar 2014 08:03:37 +0000 (+0000) Subject: [OPENMP] Small update in threadprivate variables processing to fix template instantia... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b293a9a424d50da3ff676493917c134d3789bd21;p=clang [OPENMP] Small update in threadprivate variables processing to fix template instantiation. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@203214 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaOpenMP.cpp b/lib/Sema/SemaOpenMP.cpp index b99b639ac2..b814706a61 100644 --- a/lib/Sema/SemaOpenMP.cpp +++ b/lib/Sema/SemaOpenMP.cpp @@ -525,8 +525,7 @@ ExprResult Sema::ActOnOpenMPIdExpression(Scope *CurScope, } QualType ExprType = VD->getType().getNonReferenceType(); - ExprResult DE = BuildDeclRefExpr(VD, ExprType, VK_RValue, Id.getLoc()); - DSAStack->addDSA(VD, cast(DE.get()), OMPC_threadprivate); + ExprResult DE = BuildDeclRefExpr(VD, ExprType, VK_LValue, Id.getLoc()); return DE; } @@ -582,6 +581,7 @@ OMPThreadPrivateDecl *Sema::CheckOMPThreadPrivateDecl( } Vars.push_back(*I); + DSAStack->addDSA(VD, DE, OMPC_threadprivate); } OMPThreadPrivateDecl *D = 0; if (!Vars.empty()) { diff --git a/test/OpenMP/threadprivate_ast_print.cpp b/test/OpenMP/threadprivate_ast_print.cpp index bf3b30550a..4d0d40e213 100644 --- a/test/OpenMP/threadprivate_ast_print.cpp +++ b/test/OpenMP/threadprivate_ast_print.cpp @@ -26,9 +26,16 @@ int a, b; #pragma omp threadprivate(d, b) // CHECK-NEXT: #pragma omp threadprivate(d,b) +template +struct ST { + static T m; + #pragma omp threadprivate(m) +}; + template T foo() { static T v; #pragma omp threadprivate(v) + v = ST::m; return v; } //CHECK: template int foo() {