[clang] Better diagnostics when assertion fails in `consteval` (PR #130458)
via cfe-commits
cfe-commits at lists.llvm.org
Sun May 11 01:11:06 PDT 2025
================
@@ -5975,9 +5975,22 @@ static bool CheckConstexprFunction(EvalInfo &Info, SourceLocation CallLoc,
Definition->hasAttr<MSConstexprAttr>())))
return true;
- if (Info.getLangOpts().CPlusPlus11) {
- const FunctionDecl *DiagDecl = Definition ? Definition : Declaration;
+ const FunctionDecl *DiagDecl = Definition ? Definition : Declaration;
+ // Special note for the assert() macro, as the normal error message falsely
+ // implies we cannot use an assertion during constant evaluation.
+ if (CallLoc.isMacroID() && DiagDecl->getIdentifier()) {
+ // FIXME: Instead of checking for an implementation-defined function,
+ // check and evaluate the assert() macro.
----------------
cor3ntin wrote:
Oh, right, we would need access to Sema, which we currently don't. Good answer! (@Endilll !)
Given that, I am satisfied with the change as is, thanks
https://github.com/llvm/llvm-project/pull/130458
More information about the cfe-commits
mailing list