[OPENMP] Small update in threadprivate variables processing to fix template instantiation.

llvm-svn: 203214
This commit is contained in:
Alexey Bataev 2014-03-07 08:03:37 +00:00
parent e1974dcd92
commit d178ad4943
2 changed files with 9 additions and 2 deletions

View File

@ -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<DeclRefExpr>(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()) {

View File

@ -26,9 +26,16 @@ int a, b;
#pragma omp threadprivate(d, b)
// CHECK-NEXT: #pragma omp threadprivate(d,b)
template <class T>
struct ST {
static T m;
#pragma omp threadprivate(m)
};
template <class T> T foo() {
static T v;
#pragma omp threadprivate(v)
v = ST<T>::m;
return v;
}
//CHECK: template <class T = int> int foo() {