[clang] Add tests for statement expression in initializers
The commit 683e83c5 [Clang][C++2b] P2242R3: Non-literal variables [...] in constexpr fixed a code generation bug when using (C-extension) statement expressions inside initializer expressions. Before that commit a nested static initializer inside the statement expression would not be emitted, causing it to be zero initialized. It is a bit surprising (at least to me) that a commit implementing a new C++ feature would fix this code generation bug. Zooming in it is the change done in ExprConstant.cpp that helps. That changes so that "ESR_Failed" is returned in more cases, causing the expression to not be deemed constant. This fixes the code generation as instead the compiler has to resort to generating a dynamic initializer. That commit also meant that some statement expressions (in particular the ones using static variables) that previously were accepted now are errors due to not being constant (matching GCC behavior). Given how a seemingly unrelated change caused this behavior to change, it is probably a good thing to add at least some rudimentary tests for these kind expressions. Differential Revision: https://reviews.llvm.org/D127201
Loading
Please sign in to comment