diff options
author | Sirraide <aeternalmail@gmail.com> | 2024-03-13 14:59:55 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-13 14:59:55 +0100 |
commit | 2cf2bc472da87bb4bf971b1448e05b9e3bd983dc (patch) | |
tree | dffe929374a7d0cc841b2b9d9107d79fa22b870f /clang/lib/CodeGen/CodeGenModule.cpp | |
parent | 424e0a825fe4d9e3bf98b63ef86edbc4fa5e3799 (diff) | |
download | llvm-2cf2bc472da87bb4bf971b1448e05b9e3bd983dc.zip llvm-2cf2bc472da87bb4bf971b1448e05b9e3bd983dc.tar.gz llvm-2cf2bc472da87bb4bf971b1448e05b9e3bd983dc.tar.bz2 |
[Clang] [CodeGen] Fix codegen bug in constant initialisation in C23 mode (#84981)
Consider the following code:
```c
bool const inf = (1.0/0.0);
```
When trying to emit the initialiser of this variable in C23, we end up
hitting a code path in codegen in `VarDecl::evaluateValueImpl()` where
we check for `IsConstantInitialization && (Ctx.getLangOpts().CPlusPlus
|| Ctx.getLangOpts().C23)`, and if that is the case and we emitted any
notes, constant evaluation fails, and as a result, codegen issues this
error:
```
<source>:1:12: error: cannot compile this static initializer yet
1 | bool const inf = (1.0/0.0);
|
```
As a fix, only fail in C23 mode if we’re initialising a `constexpr`
variable.
This fixes #84784.
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
0 files changed, 0 insertions, 0 deletions