[clang] [Clang] Treat constexpr-unknown value as invalid in `EvaluateAsInitializer` (PR #128409)

Eli Friedman via cfe-commits cfe-commits at lists.llvm.org
Fri Feb 28 17:16:14 PST 2025


efriedma-quic wrote:

Here's a testcase that's should generate a diagnostic, but doesn't without this patch:

```
int &ff(); int &x = ff(); constinit int &z = x;
```

Some related testcases are a little weird... consider the following:

```
extern int &x; int &z = x;
```

There's a gap between checking for constant expressions, and codegen, due to the following diagnostic; it triggers in constexpr, but allows evaluating for the value because a CCEDiag doesn't stop the evaluation: https://github.com/llvm/llvm-project/blob/52c81598da38532c119db9c06fcc3d7f9c332a8e/clang/lib/AST/ExprConstant.cpp#L3607 .

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


More information about the cfe-commits mailing list