aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3/python/libstdcxx
diff options
context:
space:
mode:
authorPatrick Palka <ppalka@redhat.com>2026-01-30 15:25:43 -0500
committerPatrick Palka <ppalka@redhat.com>2026-01-30 15:25:43 -0500
commite4c57e146a224d0aaa71ace78f96fca1156add24 (patch)
treeba3ccc955db91056d7015e4fad9c6de61444a82f /libstdc++-v3/python/libstdcxx
parentc1fa15791ae458e1bd8db6842dfc021230521a65 (diff)
downloadgcc-master.zip
gcc-master.tar.gz
gcc-master.tar.bz2
c++: non-empty constexpr constructor bodies in C++11 [PR123845]HEADtrunkmaster
This patch makes us support C++14 non-empty constexpr constructor bodies in C++11, as an extension. This will make it trivial to safely fix the C++11 library regression PR114865 that requires us to do __builtin_clear_padding after initializing _M_i in std::atomic's single-parameter constructor, and that's not really possible with the C++11 constexpr restrictions. Since we lower member initializers to constructor body statements internally, and so constructor bodies are already effectively non-empty internally even in C++11, supporting non-empty bodies in user code is mostly a matter of relaxing the parse-time error. But constexpr-ex3.C revealed that by accepting the non-empty body of A's constructor, build_data_member_initialization goes on to mistake the 'i = _i' assignment as a member initializer, and we incorrectly accept the constructor in C++11 mode (even though omitting mem-inits is only valid since C++20). Turns out this is caused by that function recognizing MODIFY_EXPR only in C++11 mode, logic that was last changed by r5-5013 (presumably to limit impact of the patch at the time) but I reckon could just be removed outright. This should be safe because the result of build_data_member_initialization is only used by cx_check_missing_mem_inits for validation; evaluation is in terms of the entire lowered constructor body. PR c++/123845 PR libstdc++/114865 gcc/cp/ChangeLog: * constexpr.cc (build_data_member_initialization): Remove C++11-specific recognition of MODIFY_EXPR. (check_constexpr_ctor_body): Relax error diagnostic to a pedwarn and don't clear DECL_DECLARED_CONSTEXPR_P upon error. Return true if complaining. gcc/testsuite/ChangeLog: * g++.dg/cpp0x/constexpr-ex3.C: Adjust C++11 non-empty constexpr constructor dg-error to a dg-warning. Expect a follow-up missing member initializer diagnostic in C++11 mode. * g++.dg/cpp2a/constexpr-try1.C: Expect a follow-up compound-statement in constexpr function diagnostic in C++11 mode. * g++.dg/cpp2a/constexpr-try2.C: Likewise. Adjust C++11 non-empty constexpr constructor dg-error to a dg-warning. * g++.dg/cpp2a/constexpr-try3.C: Adjust C++11 non-empty constexpr constructor dg-error to a dg-warning. * g++.dg/cpp0x/constexpr-ctor23.C: New test. Reviewed-by: Jason Merrill <jason@redhat.com>
Diffstat (limited to 'libstdc++-v3/python/libstdcxx')
0 files changed, 0 insertions, 0 deletions