DSAStack->getTaskgroupReductionRef(), DSAStack->isCancelRegion());
}
-/// detach and mergeable clauses are mutially exclusive, check for it.
-static bool checkDetachMergeableClauses(Sema &S,
- ArrayRef<OMPClause *> Clauses) {
+/// Find and diagnose mutually exclusive clause kinds.
+static bool checkMutuallyExclusiveClauses(
+ Sema &S, ArrayRef<OMPClause *> Clauses,
+ ArrayRef<OpenMPClauseKind> MutuallyExclusiveClauses) {
const OMPClause *PrevClause = nullptr;
bool ErrorFound = false;
for (const OMPClause *C : Clauses) {
- if (C->getClauseKind() == OMPC_detach ||
- C->getClauseKind() == OMPC_mergeable) {
+ if (llvm::is_contained(MutuallyExclusiveClauses, C->getClauseKind())) {
if (!PrevClause) {
PrevClause = C;
} else if (PrevClause->getClauseKind() != C->getClauseKind()) {
// OpenMP 5.0, 2.10.1 task Construct
// If a detach clause appears on the directive, then a mergeable clause cannot
// appear on the same directive.
- if (checkDetachMergeableClauses(*this, Clauses))
+ if (checkMutuallyExclusiveClauses(*this, Clauses,
+ {OMPC_detach, OMPC_mergeable}))
return StmtError();
auto *CS = cast<CapturedStmt>(AStmt);
CancelRegion);
}
-static bool checkGrainsizeNumTasksClauses(Sema &S,
- ArrayRef<OMPClause *> Clauses) {
- const OMPClause *PrevClause = nullptr;
- bool ErrorFound = false;
- for (const OMPClause *C : Clauses) {
- if (C->getClauseKind() == OMPC_grainsize ||
- C->getClauseKind() == OMPC_num_tasks) {
- if (!PrevClause)
- PrevClause = C;
- else if (PrevClause->getClauseKind() != C->getClauseKind()) {
- S.Diag(C->getBeginLoc(), diag::err_omp_clauses_mutually_exclusive)
- << getOpenMPClauseName(C->getClauseKind())
- << getOpenMPClauseName(PrevClause->getClauseKind());
- S.Diag(PrevClause->getBeginLoc(), diag::note_omp_previous_clause)
- << getOpenMPClauseName(PrevClause->getClauseKind());
- ErrorFound = true;
- }
- }
- }
- return ErrorFound;
-}
-
static bool checkReductionClauseWithNogroup(Sema &S,
ArrayRef<OMPClause *> Clauses) {
const OMPClause *ReductionClause = nullptr;
// OpenMP, [2.9.2 taskloop Construct, Restrictions]
// The grainsize clause and num_tasks clause are mutually exclusive and may
// not appear on the same taskloop directive.
- if (checkGrainsizeNumTasksClauses(*this, Clauses))
+ if (checkMutuallyExclusiveClauses(*this, Clauses,
+ {OMPC_grainsize, OMPC_num_tasks}))
return StmtError();
// OpenMP, [2.9.2 taskloop Construct, Restrictions]
// If a reduction clause is present on the taskloop directive, the nogroup
// OpenMP, [2.9.2 taskloop Construct, Restrictions]
// The grainsize clause and num_tasks clause are mutually exclusive and may
// not appear on the same taskloop directive.
- if (checkGrainsizeNumTasksClauses(*this, Clauses))
+ if (checkMutuallyExclusiveClauses(*this, Clauses,
+ {OMPC_grainsize, OMPC_num_tasks}))
return StmtError();
// OpenMP, [2.9.2 taskloop Construct, Restrictions]
// If a reduction clause is present on the taskloop directive, the nogroup
// OpenMP, [2.9.2 taskloop Construct, Restrictions]
// The grainsize clause and num_tasks clause are mutually exclusive and may
// not appear on the same taskloop directive.
- if (checkGrainsizeNumTasksClauses(*this, Clauses))
+ if (checkMutuallyExclusiveClauses(*this, Clauses,
+ {OMPC_grainsize, OMPC_num_tasks}))
return StmtError();
// OpenMP, [2.9.2 taskloop Construct, Restrictions]
// If a reduction clause is present on the taskloop directive, the nogroup
// OpenMP, [2.9.2 taskloop Construct, Restrictions]
// The grainsize clause and num_tasks clause are mutually exclusive and may
// not appear on the same taskloop directive.
- if (checkGrainsizeNumTasksClauses(*this, Clauses))
+ if (checkMutuallyExclusiveClauses(*this, Clauses,
+ {OMPC_grainsize, OMPC_num_tasks}))
return StmtError();
// OpenMP, [2.9.2 taskloop Construct, Restrictions]
// If a reduction clause is present on the taskloop directive, the nogroup
// OpenMP, [2.9.2 taskloop Construct, Restrictions]
// The grainsize clause and num_tasks clause are mutually exclusive and may
// not appear on the same taskloop directive.
- if (checkGrainsizeNumTasksClauses(*this, Clauses))
+ if (checkMutuallyExclusiveClauses(*this, Clauses,
+ {OMPC_grainsize, OMPC_num_tasks}))
return StmtError();
// OpenMP, [2.9.2 taskloop Construct, Restrictions]
// If a reduction clause is present on the taskloop directive, the nogroup
// OpenMP, [2.9.2 taskloop Construct, Restrictions]
// The grainsize clause and num_tasks clause are mutually exclusive and may
// not appear on the same taskloop directive.
- if (checkGrainsizeNumTasksClauses(*this, Clauses))
+ if (checkMutuallyExclusiveClauses(*this, Clauses,
+ {OMPC_grainsize, OMPC_num_tasks}))
return StmtError();
// OpenMP, [2.9.2 taskloop Construct, Restrictions]
// If a reduction clause is present on the taskloop directive, the nogroup