[all-commits] [llvm/llvm-project] 2cf2bc: [Clang] [CodeGen] Fix codegen bug in constant init...
Sirraide via All-commits
all-commits at lists.llvm.org
Wed Mar 13 07:00:17 PDT 2024
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 2cf2bc472da87bb4bf971b1448e05b9e3bd983dc
https://github.com/llvm/llvm-project/commit/2cf2bc472da87bb4bf971b1448e05b9e3bd983dc
Author: Sirraide <aeternalmail at gmail.com>
Date: 2024-03-13 (Wed, 13 Mar 2024)
Changed paths:
M clang/lib/AST/Decl.cpp
M clang/test/CodeGen/const-init.c
A clang/test/Sema/const-init.c
Log Message:
-----------
[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.
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list