[clang] [Clang] Implement P2280R4 Using unknown pointers and references in constant expressions (PR #95474)

A. Jiang via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 13 22:55:29 PDT 2024


================
@@ -3300,6 +3308,11 @@ static bool HandleLValueComplexElement(EvalInfo &Info, const Expr *E,
 static bool evaluateVarDeclInit(EvalInfo &Info, const Expr *E,
                                 const VarDecl *VD, CallStackFrame *Frame,
                                 unsigned Version, APValue *&Result) {
+  // P2280R4 If we have a reference type and we are in C++23 allow unknown
+  // references and pointers.
+  bool AllowConstexprUnknown =
+      Info.getLangOpts().CPlusPlus23 && VD->getType()->isReferenceType();
----------------
frederick-vs-ja wrote:

This is a DR per [N4916](https://wg21.link/n4916) (ditto below).
```suggestion
  // P2280R4 allow unknown references and pointers.
  bool AllowConstexprUnknown = VD->getType()->isReferenceType();
```

https://github.com/llvm/llvm-project/pull/95474


More information about the cfe-commits mailing list