[OPENMP] Fix crash on private variables not used in OpenMP region in templates.
llvm-svn: 233913
This commit is contained in:
parent
3ebba5237e
commit
8bf6b3eaf7
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -45,6 +45,8 @@ T tmain() {
|
|||
vec[0] = t_var;
|
||||
s_arr[0] = var;
|
||||
}
|
||||
#pragma omp parallel firstprivate(t_var)
|
||||
{}
|
||||
return T();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue