================
@@ -3566,6 +3613,21 @@ static bool evaluateVarDeclInit(EvalInfo &Info, const 
Expr *E,
   }
 
   Result = VD->getEvaluatedValue();
+
+  // C++23 [expr.const]p8
+  // ... For such an object that is not usable in constant expressions, the
+  // dynamic type of the object is constexpr-unknown. For such a reference that
+  // is not usable in constant expressions, the reference is treated as binding
+  // to an unspecified object of the referenced type whose lifetime and that of
+  // all subobjects includes the entire constant evaluation and whose dynamic
+  // type is constexpr-unknown.
+  if (AllowConstexprUnknown) {
+    if (!Result) {
+      Result = &Info.CurrentCall->createConstexprUnknownAPValues(VD, Base);
+    } else {
+      Result->setConstexprUnknown();
+    }
----------------
cor3ntin wrote:

```suggestion
    if (!Result)
      Result = &Info.CurrentCall->createConstexprUnknownAPValues(VD, Base);
    else
      Result->setConstexprUnknown();
```

(Or use a ternary)

https://github.com/llvm/llvm-project/pull/95474
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to