]> git.ipfire.org Git - thirdparty/gcc.git/commit
libstdc++: Simplify constexpr checks in std::char_traits [PR 91488]
authorJonathan Wakely <jwakely@redhat.com>
Thu, 17 Jun 2021 13:11:22 +0000 (14:11 +0100)
committerJonathan Wakely <jwakely@redhat.com>
Fri, 18 Jun 2021 10:16:52 +0000 (11:16 +0100)
commit0191c74141cfea8973a6d977ce9944d39f7c4329
treee7bac3f713b234164074e61e69a66c709ed894b5
parent3587c2c241eda0f3ab54ea60d46e9caf12d69b5a
libstdc++: Simplify constexpr checks in std::char_traits [PR 91488]

This removes the 'static' keyword from the helper functions added by
r8-1294 to detect whether the char_traits member functions can be
evaluated at compile time. This prevents the "inlining failed" error
reported in the PR.

The new testcase from the PR is added to the libitm testsuite, because
that's where we can be sure it's OK to use the -fgnu-tm option.

As a drive-by fix, the feature test macros for C++20 P0980R1 support are
made to depend on whether __cpp_lib_is_constant_evaluated is defined.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
PR libstdc++/91488

libstdc++-v3/ChangeLog:

* include/bits/basic_string.h (__cpp_lib_constexpr_string): Only
define C++20 value when std::is_constant_evaluated is available.
* include/bits/char_traits.h (__cpp_lib_constexpr_char_traits):
Likewise.
(__constant_string_p, __constant_array_p): Give external
linkage.
* include/std/version (__cpp_lib_constexpr_char_traits)
(__cpp_lib_constexpr_string): Only define C++20 values when
is_constant_evaluated is available.

libitm/ChangeLog:

* testsuite/libitm.c++/libstdc++-pr91488.C: New test.

(cherry picked from commit b376b1ef38971b84975ad1540bf5d2ae0b924e76)
libitm/testsuite/libitm.c++/libstdc++-pr91488.C [new file with mode: 0644]
libstdc++-v3/include/bits/basic_string.h
libstdc++-v3/include/bits/char_traits.h
libstdc++-v3/include/std/version