================
@@ -13621,23 +13621,64 @@ 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());
+/// Check the number of expressions specified in a multidimensional clause and
+/// return whether an error was encountered.
+template <typename ClauseT>
+static bool checkExprsInMultidimClause(SemaBase &SemaRef, const ClauseT 
*Clause,
+                                       const OMPXBareClause *BareClause) {
+  if (!Clause)
     return false;
+
+  const uint64_t NumVars = Clause->getVarRefs().size();
+
+  // The ompx_bare clause allows up to three expressions.
+  if (BareClause && NumVars > 3) {
+    SemaRef.Diag(Clause->getBeginLoc(),
+                 diag::err_ompx_more_than_three_expr_not_allowed)
+        << getOpenMPClauseName(Clause->getClauseKind());
+    return true;
   }
-  return true;
+
+  // Only one expression is allowed otherwise.
+  if (!BareClause && NumVars != 1) {
+    SemaRef.Diag(Clause->getBeginLoc(), diag::err_omp_multi_expr_not_allowed)
+        << getOpenMPClauseName(Clause->getClauseKind());
+    return true;
+  }
+  return false;
+}
+
+/// Check the number of expressions specified in clauses that can contain
+/// multidimensional values, e.g., num_teams and thread_limit. The function
+/// returns true on error.
+static bool checkMultidimClauses(SemaBase &SemaRef,
+                                 ArrayRef<OMPClause *> Clauses,
+                                 bool MayHaveBareClause = false) {
+  auto BareClauseIt =
+      (MayHaveBareClause)
----------------
shiltian wrote:

```suggestion
      MayHaveBareClause
```

https://github.com/llvm/llvm-project/pull/207305
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to