[clang] [C23] Implement N3018: The constexpr specifier for object definitions (PR #73099)

Mariya Podchishchaeva via cfe-commits cfe-commits at lists.llvm.org
Wed Nov 29 03:29:29 PST 2023


================
@@ -4110,6 +4116,10 @@ static CompleteObject findCompleteObject(EvalInfo &Info, const Expr *E,
     }
 
     bool IsConstant = BaseType.isConstant(Info.Ctx);
+    bool ConstexprVar = false;
+    if (const auto *VD = dyn_cast_if_present<VarDecl>(
+            Info.EvaluatingDecl.dyn_cast<const ValueDecl *>()))
+      ConstexprVar = VD->isConstexpr();
----------------
Fznamznon wrote:

This is to check that an initializer for a `constexpr` variable in c23 can only reference other `constexpr` variables. Done since C++ allows things like
```
const int a = 0;
constexpr int b = a;
```

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


More information about the cfe-commits mailing list