diff options
author | Jonathan Wakely <jwakely@redhat.com> | 2022-01-05 14:25:37 +0000 |
---|---|---|
committer | Jonathan Wakely <jwakely@redhat.com> | 2022-01-05 14:43:01 +0000 |
commit | 3633cc54284450433b81f0340483e15df1a49a3c (patch) | |
tree | 8999cf5da81331352168bc23b5c930a1e90822d0 /libstdc++-v3/config/abi/pre | |
parent | 096228d84e9238d97fe115623126373f5b67bdc1 (diff) | |
download | gcc-3633cc54284450433b81f0340483e15df1a49a3c.zip gcc-3633cc54284450433b81f0340483e15df1a49a3c.tar.gz gcc-3633cc54284450433b81f0340483e15df1a49a3c.tar.bz2 |
libstdc++: Implement P1328 "Making std::type_info::operator== constexpr"
This feature is present in the C++23 draft.
With Jakub's recent front-end changes we can implement constexpr
equality by comparing the addresses of std::type_info objects. We do not
need string comparisons, because for constant evaluation cases we know
we aren't dealing with std::type_info objects defined in other
translation units.
The ARM EABI requires that the type_info::operator== function can be
defined out-of-line (and suggests that should be the default), but to be
a constexpr function it must be defined inline (at least for C++23
mode). To meet these conflicting requirements we make the inline version
of operator== call a new __equal function when called at runtime. That
is an alias for the non-inline definition of operator== defined in
libsupc++.
libstdc++-v3/ChangeLog:
* config/abi/pre/gnu.ver (GLIBCXX_3.4.30): Export new symbol for
ARM EABI.
* include/bits/c++config (_GLIBCXX23_CONSTEXPR): Define.
* include/std/version (__cpp_lib_constexpr_typeinfo): Define.
* libsupc++/tinfo.cc: Add #error to ensure non-inline definition
is emitted.
(type_info::__equal): Define alias symbol.
* libsupc++/typeinfo (type_info::before): Combine different
implementations into one.
(type_info::operator==): Likewise. Use address equality for
constant evaluation. Call __equal for targets that require the
definition to be non-inline.
* testsuite/18_support/type_info/constexpr.cc: New test.
Diffstat (limited to 'libstdc++-v3/config/abi/pre')
-rw-r--r-- | libstdc++-v3/config/abi/pre/gnu.ver | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/libstdc++-v3/config/abi/pre/gnu.ver b/libstdc++-v3/config/abi/pre/gnu.ver index c2f09a9..afd242b 100644 --- a/libstdc++-v3/config/abi/pre/gnu.ver +++ b/libstdc++-v3/config/abi/pre/gnu.ver @@ -2424,6 +2424,9 @@ GLIBCXX_3.4.30 { # std::__timepunct<char>::_M_am_pm_format(const char**) _ZNKSt11__timepunctI[cw]E15_M_am_pm_formatEPPK[cw]; + # Only defined #if ! __GXX_TYPEINFO_EQUALITY_INLINE + _ZNKSt9type_info7__equalERKS_; + } GLIBCXX_3.4.29; # Symbols in the support library (libsupc++) have their own tag. |