diff options
author | Jonathan Wakely <jwakely@redhat.com> | 2021-06-17 14:11:22 +0100 |
---|---|---|
committer | Jonathan Wakely <jwakely@redhat.com> | 2021-06-17 22:00:58 +0100 |
commit | b376b1ef38971b84975ad1540bf5d2ae0b924e76 (patch) | |
tree | e81a073a91795524bc4a7241d9ac7987d82861e6 /libitm | |
parent | 331e20a69be0d9e7d448580945945d4c7a1e3c0a (diff) | |
download | gcc-b376b1ef38971b84975ad1540bf5d2ae0b924e76.zip gcc-b376b1ef38971b84975ad1540bf5d2ae0b924e76.tar.gz gcc-b376b1ef38971b84975ad1540bf5d2ae0b924e76.tar.bz2 |
libstdc++: Simplify constexpr checks in std::char_traits [PR 91488]
This removes the helper functions added by r8-1294 to detect whether the
char_traits member functions can be evaluated at compile time. Instead,
we can just use __builtin_constant_evaluated directly, which is well
supported by non-GCC compilers by now.
As a result, there is a chance that those members will no longer be
usable in constant expressions when using old versions of non-GCC
compilers. Make the relevant feature test macros depend on the
availability of __builtin_constant_evaluated, so they are defined only
when the feature is actualyl available.
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.
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 when is_constant_evaluated is available.
* include/bits/char_traits.h (__cpp_lib_constexpr_char_traits):
Likewise.
(__constant_string_p, __constant_array_p): Remove.
(char_traits): Use is_constant_evaluated directly.
* include/std/version (__cpp_lib_constexpr_char_traits)
(__cpp_lib_constexpr_string): Only define when
is_constant_evaluated is available.
libitm/ChangeLog:
* testsuite/libitm.c++/libstdc++-pr91488.C: New test.
Diffstat (limited to 'libitm')
-rw-r--r-- | libitm/testsuite/libitm.c++/libstdc++-pr91488.C | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/libitm/testsuite/libitm.c++/libstdc++-pr91488.C b/libitm/testsuite/libitm.c++/libstdc++-pr91488.C new file mode 100644 index 0000000..e9e82bd --- /dev/null +++ b/libitm/testsuite/libitm.c++/libstdc++-pr91488.C @@ -0,0 +1,9 @@ +// PR libstdc++/91488 "inlining failed in call to always_inline" +// { dg-do run } +// { dg-additional-options "-O1" } + +#include <string> + +int main() { + return std::char_traits<char>::length(""); +} |