[clang] [OpenMP] Add assertion for 'factor' width mismatch in 'unroll partial' (PR #139986)

ALBIN BABU VARGHESE via cfe-commits cfe-commits at lists.llvm.org
Thu May 15 01:29:38 PDT 2025


================
@@ -14924,8 +14924,24 @@ StmtResult SemaOpenMP::ActOnOpenMPUnrollDirective(ArrayRef<OMPClause *> Clauses,
   SourceLocation FactorLoc;
   if (Expr *FactorVal = PartialClause->getFactor();
       FactorVal && !FactorVal->containsErrors()) {
+    if (!VerifyPositiveIntegerConstantInClause(FactorVal, OMPC_partial,
+                                               /*StrictlyPositive=*/true,
+                                               /*SuppressExprDiags=*/false)
+             .isUsable()) {
+      return StmtError();
+    }
+    // Checking if Itertor Variable Type can hold the Factor Width
+    if (FactorVal->getIntegerConstantExpr(Context)->getBitWidth() >
----------------
albus-droid wrote:

I created two local variables `FactorValWidth` and `IteratorVWidth` to use in both places.

https://github.com/llvm/llvm-project/pull/139986


More information about the cfe-commits mailing list