Skip to content

Commit fd2cd3d

Browse files
committed
Added diag error message and also formatted using clang-format
1 parent 2801d23 commit fd2cd3d

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11700,6 +11700,8 @@ def err_omp_negative_expression_in_clause : Error<
1170011700
"argument to '%0' clause must be a %select{non-negative|strictly positive}1 integer value">;
1170111701
def err_omp_large_expression_in_clause : Error<
1170211702
"argument to '%0' clause requires a value that can be represented by a 64-bit">;
11703+
def err_omp_unroll_factor_width_mismatch : Error<
11704+
"unroll factor has width %0 but the iteration variable %1 is only %2 bits wide">;
1170311705
def err_omp_not_integral : Error<
1170411706
"expression must have integral or unscoped enumeration "
1170511707
"type, not %0">;

clang/lib/Sema/SemaOpenMP.cpp

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14980,13 +14980,19 @@ 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();
14983+
if (!VerifyPositiveIntegerConstantInClause(FactorVal, OMPC_partial,
14984+
/*StrictlyPositive=*/true,
14985+
/*SuppressExprDiags=*/false)
14986+
.isUsable()) {
14987+
return StmtError();
1498514988
}
1498614989
// 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+
if (FactorVal->getIntegerConstantExpr(Context)->getBitWidth() >
14991+
Context.getTypeSize(IVTy)) {
14992+
Diag(FactorVal->getExprLoc(), diag::err_omp_unroll_factor_width_mismatch)
14993+
<< FactorVal->getIntegerConstantExpr(Context)->getBitWidth() << IVTy
14994+
<< Context.getTypeSize(IVTy);
14995+
return StmtError();
1499014996
}
1499114997

1499214998
Factor = FactorVal->getIntegerConstantExpr(Context)->getZExtValue();

0 commit comments

Comments
 (0)