================
@@ -13621,23 +13621,69 @@ StmtResult
SemaOpenMP::ActOnOpenMPTargetUpdateDirective(
Clauses, AStmt);
}
-/// This checks whether a \p ClauseType clause \p C has at most \p Max
-/// expression. If not, a diag of number \p Diag will be emitted.
-template <typename ClauseType>
-static bool checkNumExprsInClause(SemaBase &SemaRef,
- ArrayRef<OMPClause *> Clauses,
- unsigned MaxNum, unsigned Diag) {
- auto ClauseItr = llvm::find_if(Clauses, llvm::IsaPred<ClauseType>);
- if (ClauseItr == Clauses.end())
- return true;
- const auto *C = cast<ClauseType>(*ClauseItr);
- auto VarList = C->getVarRefs();
- if (VarList.size() > MaxNum) {
- SemaRef.Diag(VarList[MaxNum]->getBeginLoc(), Diag)
- << getOpenMPClauseNameForDiag(C->getClauseKind());
+template <typename ClauseT>
+static bool checkClauseNumExprs(SemaBase &SemaRef, const ClauseT *Clause,
+ const OMPXBareClause *BareClause) {
+ if (!Clause)
return false;
+
+ uint64_t MaxExprs = BareClause ? 3 : 1;
+
+ const Expr *DimsExpr = Clause->getDimsModifierExpr();
+ if (DimsExpr) {
+ // Cannot verify the size yet.
+ if (DimsExpr->isInstantiationDependent())
+ return false;
+
+ MaxExprs =
+ DimsExpr->EvaluateKnownConstInt(SemaRef.getASTContext()).getExtValue();
}
- return true;
+
+ size_t NumVars = Clause->getVarRefs().size();
+ if (NumVars > MaxExprs) {
+ SemaRef.Diag(Clause->getBeginLoc(), diag::err_omp_unexpected_num_exprs)
+ << getOpenMPClauseName(Clause->getClauseKind());
+ return true;
+ }
+ if (NumVars > 3) {
----------------
alexey-bataev wrote:
Diagnostic-quality regression for the pre-existing non-dims case. `num_teams(1,
2, 3) / thread_limit(1, 2, 3)` previously resulted in "only one expression
allowed in '%0' clause"; now produces "unexpected number of expressions in '%0'
clause"
https://github.com/llvm/llvm-project/pull/206412
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits