kkwli0 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, ---------------- ABataev wrote: > Use Sema::VerifyPositiveIntegerConstantInClause() instead. num_teams/thread_limit/num_threads is not required to be a constant. Using Sema::VerifyPositiveIntegerConstantInClause() will impose a stricter constraint.
http://reviews.llvm.org/D15029 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits