[clang] [clang] fix constexpr-unknown handling of self-references. (PR #132990)
via cfe-commits
cfe-commits at lists.llvm.org
Wed Mar 26 02:04:02 PDT 2025
================
@@ -3485,11 +3485,27 @@ static bool evaluateVarDeclInit(EvalInfo &Info, const Expr *E,
APValue::LValueBase Base(VD, Frame ? Frame->Index : 0, Version);
+ auto CheckUninitReference = [&] {
+ if (!Result->hasValue() && VD->getType()->isReferenceType()) {
+ // We can't use an uninitialized reference directly.
+ if (!AllowConstexprUnknown) {
+ if (!Info.checkingPotentialConstantExpression())
+ Info.FFDiag(E, diag::note_constexpr_use_uninit_reference);
+ return false;
+ }
+ Result = &Info.CurrentCall->createConstexprUnknownAPValues(VD, Base);
+ }
+ return true;
+ };
+
----------------
cor3ntin wrote:
I think this could use a comment
https://github.com/llvm/llvm-project/pull/132990
More information about the cfe-commits
mailing list