[clang] [clang][bytecode] Diagnose reference to non-constexpr variable of const type in C23 constexpr (PR #112211)

Timm Baeder via cfe-commits cfe-commits at lists.llvm.org
Mon Oct 14 08:49:13 PDT 2024


================
@@ -348,6 +348,12 @@ bool CheckConstant(InterpState &S, CodePtr OpPC, const Descriptor *Desc) {
   if (D->isConstexpr())
     return true;
 
+  if (const auto *VD = dyn_cast_if_present<VarDecl>(S.EvaluatingDecl);
+      VD && VD->isConstexpr() && S.getLangOpts().C23) {
+    S.FFDiag(S.Current->getExpr(OpPC));
----------------
tbaederr wrote:

```suggestion
    return Invalid(S, OpPC)
```
should work here as well.

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


More information about the cfe-commits mailing list