Skip to content

Commit e6a6544

Browse files
committed
Summary: builtin function can accept a constant variable.
1 parent cb355de commit e6a6544

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

clang/lib/Sema/SemaChecking.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5666,11 +5666,12 @@ bool Sema::BuiltinConstantArg(CallExpr *TheCall, int ArgNum,
56665666

56675667
if (Arg->isTypeDependent() || Arg->isValueDependent()) return false;
56685668

5669-
std::optional<llvm::APSInt> R;
5670-
if (!(R = Arg->getIntegerConstantExpr(Context)))
5669+
Expr::EvalResult evalRes;
5670+
if (!Arg->EvaluateAsInt(evalRes, Context)) {
56715671
return Diag(TheCall->getBeginLoc(), diag::err_constant_integer_arg_type)
56725672
<< FDecl->getDeclName() << Arg->getSourceRange();
5673-
Result = *R;
5673+
}
5674+
Result = evalRes.Val.getInt();
56745675
return false;
56755676
}
56765677

0 commit comments

Comments
 (0)