From: Jonathan Wakely <jwakely@redhat.com>
To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org
Subject: [committed] libstdc++: Adjust <format> for Clang compatibility [PR107712]
Date: Wed, 16 Nov 2022 21:00:06 +0000 [thread overview]
Message-ID: <20221116210006.1420105-1-jwakely@redhat.com> (raw)
Tested x86_64-linux. Pushed to trunk.
-- >8 --
Clang doesn't define __builtin_toupper, so use std::toupper.
Also add some (not actually required since C++20) typename keywords to
help Clang versions up to and including 15.
libstdc++-v3/ChangeLog:
PR libstdc++/107712
* include/std/format (__format::__formatter_int::format): Use
std::toupper when __builtin_toupper isn't available.
(basic_format_arg::handle): Add 'typename'.
* include/std/complex (complex<T>): Add 'typename'.
---
libstdc++-v3/include/std/complex | 2 +-
libstdc++-v3/include/std/format | 10 +++++++++-
2 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/libstdc++-v3/include/std/complex b/libstdc++-v3/include/std/complex
index 7fed8a7757c..86d5ca3c3e1 100644
--- a/libstdc++-v3/include/std/complex
+++ b/libstdc++-v3/include/std/complex
@@ -1840,7 +1840,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{
public:
typedef _Tp value_type;
- typedef std::__complex_type<_Tp>::type _ComplexT;
+ typedef typename std::__complex_type<_Tp>::type _ComplexT;
constexpr complex(_ComplexT __z) : _M_value(__z) { }
diff --git a/libstdc++-v3/include/std/format b/libstdc++-v3/include/std/format
index fb29f7e7835..995b05c2ab2 100644
--- a/libstdc++-v3/include/std/format
+++ b/libstdc++-v3/include/std/format
@@ -52,6 +52,10 @@
#include <bits/utility.h> // tuple_size_v
#include <ext/numeric_traits.h> // __int_traits
+#if !__has_builtin(__builtin_toupper)
+# include <cctype>
+#endif
+
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
@@ -1027,7 +1031,11 @@ namespace __format
__res = to_chars(__start, __end, __u, 16);
if (_M_spec._M_type == _Pres_X)
for (auto __p = __start; __p != __res.ptr; ++__p)
+#if __has_builtin(__builtin_toupper)
*__p = __builtin_toupper(*__p);
+#else
+ *__p = std::toupper(*__p);
+#endif
break;
default:
__builtin_unreachable();
@@ -2718,7 +2726,7 @@ namespace __format
public:
class handle : public __format::_Arg_value<_Context>::_HandleBase
{
- using _Base = __format::_Arg_value<_Context>::_HandleBase;
+ using _Base = typename __format::_Arg_value<_Context>::_HandleBase;
// Format as const if possible, to reduce instantiations.
template<typename _Tp>
--
2.38.1
reply other threads:[~2022-11-16 21:00 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221116210006.1420105-1-jwakely@redhat.com \
--to=jwakely@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=libstdc++@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).