[PATCH] D15029: [OpenMP] Parsing and sema support for thread_limit clause

Alexey Bataev via cfe-commits cfe-commits at lists.llvm.org
Thu Nov 26 20:13:45 PST 2015


ABataev added inline comments.

================
Comment at: lib/Sema/SemaOpenMP.cpp:5220-5242
@@ -5216,2 +5219,25 @@
 
+static bool IsNonNegativeIntegerValue(Expr *&ValExpr, Sema &SemaRef,
+                                      OpenMPClauseKind CKind) {
+  if (!ValExpr->isTypeDependent() && !ValExpr->isValueDependent() &&
+      !ValExpr->isInstantiationDependent()) {
+    SourceLocation Loc = ValExpr->getExprLoc();
+    ExprResult Value =
+        SemaRef.PerformOpenMPImplicitIntegerConversion(Loc, ValExpr);
+    if (Value.isInvalid())
+      return false;
+
+    ValExpr = Value.get();
+    // The expression must evaluate to a non-negative integer value.
+    llvm::APSInt Result;
+    if (ValExpr->isIntegerConstantExpr(Result, SemaRef.Context) &&
+        Result.isSigned() && !Result.isStrictlyPositive()) {
+      SemaRef.Diag(Loc, diag::err_omp_negative_expression_in_clause)
+          << getOpenMPClauseName(CKind) << ValExpr->getSourceRange();
+      return false;
+    }
+  }
+  return true;
+}
+
 OMPClause *Sema::ActOnOpenMPNumThreadsClause(Expr *NumThreads,
----------------
Use Sema::VerifyPositiveIntegerConstantInClause() instead.


http://reviews.llvm.org/D15029





More information about the cfe-commits mailing list