diff options
Diffstat (limited to 'clang/lib')
| -rw-r--r-- | clang/lib/Sema/SemaOpenMP.cpp | 45 |
1 files changed, 12 insertions, 33 deletions
diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp index 20581af180c..68497cb2df5 100644 --- a/clang/lib/Sema/SemaOpenMP.cpp +++ b/clang/lib/Sema/SemaOpenMP.cpp @@ -6808,17 +6808,6 @@ StmtResult Sema::ActOnOpenMPDistributeParallelForDirective( assert((CurContext->isDependentContext() || B.builtAll()) && "omp for loop exprs were not built"); - if (!CurContext->isDependentContext()) { - // Finalize the clauses that need pre-built expressions for CodeGen. - for (auto C : Clauses) { - if (auto *LC = dyn_cast<OMPLinearClause>(C)) - if (FinishOpenMPLinearClause(*LC, cast<DeclRefExpr>(B.IterationVarRef), - B.NumIterations, *this, CurScope, - DSAStack)) - return StmtError(); - } - } - getCurFunction()->setHasBranchProtectedScope(); return OMPDistributeParallelForDirective::Create( Context, StartLoc, EndLoc, NestedLoopCount, Clauses, AStmt, B, @@ -7223,17 +7212,6 @@ StmtResult Sema::ActOnOpenMPTeamsDistributeParallelForDirective( assert((CurContext->isDependentContext() || B.builtAll()) && "omp for loop exprs were not built"); - if (!CurContext->isDependentContext()) { - // Finalize the clauses that need pre-built expressions for CodeGen. - for (auto C : Clauses) { - if (auto *LC = dyn_cast<OMPLinearClause>(C)) - if (FinishOpenMPLinearClause(*LC, cast<DeclRefExpr>(B.IterationVarRef), - B.NumIterations, *this, CurScope, - DSAStack)) - return StmtError(); - } - } - getCurFunction()->setHasBranchProtectedScope(); return OMPTeamsDistributeParallelForDirective::Create( Context, StartLoc, EndLoc, NestedLoopCount, Clauses, AStmt, B, @@ -7334,17 +7312,6 @@ StmtResult Sema::ActOnOpenMPTargetTeamsDistributeParallelForDirective( assert((CurContext->isDependentContext() || B.builtAll()) && "omp target teams distribute parallel for loop exprs were not built"); - if (!CurContext->isDependentContext()) { - // Finalize the clauses that need pre-built expressions for CodeGen. - for (auto C : Clauses) { - if (auto *LC = dyn_cast<OMPLinearClause>(C)) - if (FinishOpenMPLinearClause(*LC, cast<DeclRefExpr>(B.IterationVarRef), - B.NumIterations, *this, CurScope, - DSAStack)) - return StmtError(); - } - } - getCurFunction()->setHasBranchProtectedScope(); return OMPTargetTeamsDistributeParallelForDirective::Create( Context, StartLoc, EndLoc, NestedLoopCount, Clauses, AStmt, B, @@ -10767,6 +10734,18 @@ static bool FinishOpenMPLinearClause(OMPLinearClause &Clause, DeclRefExpr *IV, continue; } auto &&Info = Stack->isLoopControlVariable(D); + // OpenMP [2.15.11, distribute simd Construct] + // A list item may not appear in a linear clause, unless it is the loop + // iteration variable. + if (isOpenMPDistributeDirective(Stack->getCurrentDirective()) && + isOpenMPSimdDirective(Stack->getCurrentDirective()) && !Info.first) { + SemaRef.Diag(ELoc, + diag::err_omp_linear_distribute_var_non_loop_iteration); + Updates.push_back(nullptr); + Finals.push_back(nullptr); + HasErrors = true; + continue; + } Expr *InitExpr = *CurInit; // Build privatized reference to the current linear var. |

