[OPENMP] Fix crash on private variables not used in OpenMP region in templates.

llvm-svn: 233913
This commit is contained in:
Alexey Bataev 2015-04-02 13:07:08 +00:00
parent 3ebba5237e
commit 8bf6b3eaf7
3 changed files with 13 additions and 2 deletions

View File

@ -1199,7 +1199,7 @@ StmtResult Sema::ActOnOpenMPRegionEnd(StmtResult S,
if (isOpenMPPrivate(Clause->getClauseKind())) {
for (auto *VarRef : Clause->children()) {
if (auto *E = cast_or_null<Expr>(VarRef)) {
MarkDeclarationsReferencedInExpr(cast<Expr>(E));
MarkDeclarationsReferencedInExpr(E);
}
}
}

View File

@ -6670,7 +6670,16 @@ StmtResult TreeTransform<Derived>::TransformOMPExecutableDirective(
if (!D->getAssociatedStmt()) {
return StmtError();
}
AssociatedStmt = getDerived().TransformStmt(D->getAssociatedStmt());
getDerived().getSema().ActOnOpenMPRegionStart(D->getDirectiveKind(),
/*CurScope=*/nullptr);
StmtResult Body;
{
Sema::CompoundScopeRAII CompoundScope(getSema());
Body = getDerived().TransformStmt(
cast<CapturedStmt>(D->getAssociatedStmt())->getCapturedStmt());
}
AssociatedStmt =
getDerived().getSema().ActOnOpenMPRegionEnd(Body, TClauses);
if (AssociatedStmt.isInvalid()) {
return StmtError();
}

View File

@ -45,6 +45,8 @@ T tmain() {
vec[0] = t_var;
s_arr[0] = var;
}
#pragma omp parallel firstprivate(t_var)
{}
return T();
}