Skip to content

Commit 2801d23

Browse files
committed
Added two conditions to check for width of the factor variable
1 parent f8a6905 commit 2801d23

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

clang/lib/Sema/SemaOpenMP.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14980,8 +14980,18 @@ StmtResult SemaOpenMP::ActOnOpenMPUnrollDirective(ArrayRef<OMPClause *> Clauses,
1498014980
SourceLocation FactorLoc;
1498114981
if (Expr *FactorVal = PartialClause->getFactor();
1498214982
FactorVal && !FactorVal->containsErrors()) {
14983+
if (!VerifyPositiveIntegerConstantInClause(FactorVal,OMPC_partial,/*StrictlyPositive=*/true,/*SuppressExprDiags=*/false).isUsable()) {
14984+
return StmtError();
14985+
}
14986+
// Checking if Itertor Variable Type can hold the Factor Width
14987+
if (FactorVal->EvaluateKnownConstInt(Context).getBitWidth() > Context.getTypeSize(IVTy)) {
14988+
Diag(FactorVal->getExprLoc(), diag::err_omp_hint_clause_no_name);
14989+
return StmtError();
14990+
}
14991+
1498314992
Factor = FactorVal->getIntegerConstantExpr(Context)->getZExtValue();
1498414993
FactorLoc = FactorVal->getExprLoc();
14994+
1498514995
} else {
1498614996
// TODO: Use a better profitability model.
1498714997
Factor = 2;

0 commit comments

Comments
 (0)