public inbox for libstdc++@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jonathan Wakely <jwakely@redhat.com>
To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org
Subject: [PATCH 5/8] libstdc++: Enable type traits for wchar_t unconditionally [PR98725]
Date: Sat,  9 Oct 2021 01:13:48 +0100	[thread overview]
Message-ID: <20211009001351.659647-5-jwakely@redhat.com> (raw)
In-Reply-To: <20211009001351.659647-1-jwakely@redhat.com>

None of these traits depend on libc support for wchar_t, so they should
be defined unconditionally. The wchar_t type is always defined in C++.

libstdc++-v3/ChangeLog:

	PR libstdc++/98725
	* include/c_global/cstddef [!_GLIBCXX_USE_WCHAR_T]
	(__byte_operand<wchar_t>): Define specialization.
	* include/std/type_traits (__make_signed<wchar_t>)
	(__make_unsigned<wchar_t>): Remove redundant check for
	__WCHAR_TYPE__ being defined.
	* include/tr1/type_traits [!_GLIBCXX_USE_WCHAR_T]
	(__is_integral_helper<wchar_t>): Likewise.
---
 libstdc++-v3/include/c_global/cstddef | 2 --
 libstdc++-v3/include/std/type_traits  | 8 +-------
 libstdc++-v3/include/tr1/type_traits  | 2 --
 3 files changed, 1 insertion(+), 11 deletions(-)

diff --git a/libstdc++-v3/include/c_global/cstddef b/libstdc++-v3/include/c_global/cstddef
index 13ef7f03c12..a96319e31ef 100644
--- a/libstdc++-v3/include/c_global/cstddef
+++ b/libstdc++-v3/include/c_global/cstddef
@@ -73,9 +73,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   template<> struct __byte_operand<char> { using __type = byte; };
   template<> struct __byte_operand<signed char> { using __type = byte; };
   template<> struct __byte_operand<unsigned char> { using __type = byte; };
-#ifdef _GLIBCXX_USE_WCHAR_T
   template<> struct __byte_operand<wchar_t> { using __type = byte; };
-#endif
 #ifdef _GLIBCXX_USE_CHAR8_T
   template<> struct __byte_operand<char8_t> { using __type = byte; };
 #endif
diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits
index 35ff5806c5d..d3693b1069e 100644
--- a/libstdc++-v3/include/std/type_traits
+++ b/libstdc++-v3/include/std/type_traits
@@ -309,12 +309,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
   // We want is_integral<wchar_t> to be true (and make_signed/unsigned to work)
   // even when libc doesn't provide working <wchar.h> and related functions,
-  // so check __WCHAR_TYPE__ instead of _GLIBCXX_USE_WCHAR_T.
-#ifdef __WCHAR_TYPE__
+  // so don't check _GLIBCXX_USE_WCHAR_T here.
   template<>
     struct __is_integral_helper<wchar_t>
     : public true_type { };
-#endif
 
 #ifdef _GLIBCXX_USE_CHAR8_T
   template<>
@@ -1828,14 +1826,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   // neither signed integer types nor unsigned integer types, so must be
   // transformed to the unsigned integer type with the smallest rank.
   // Use the partial specialization for enumeration types to do that.
-#ifdef __WCHAR_TYPE__
   template<>
     struct __make_unsigned<wchar_t>
     {
       using __type
 	= typename __make_unsigned_selector<wchar_t, false, true>::__type;
     };
-#endif
 
 #ifdef _GLIBCXX_USE_CHAR8_T
   template<>
@@ -1960,14 +1956,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   // signed integer types nor unsigned integer types, so must be
   // transformed to the signed integer type with the smallest rank.
   // Use the partial specialization for enumeration types to do that.
-#if defined(__WCHAR_TYPE__)
   template<>
     struct __make_signed<wchar_t>
     {
       using __type
 	= typename __make_signed_selector<wchar_t, false, true>::__type;
     };
-#endif
 
 #if defined(_GLIBCXX_USE_CHAR8_T)
   template<>
diff --git a/libstdc++-v3/include/tr1/type_traits b/libstdc++-v3/include/tr1/type_traits
index e62369c9f4c..16d7e338bfe 100644
--- a/libstdc++-v3/include/tr1/type_traits
+++ b/libstdc++-v3/include/tr1/type_traits
@@ -109,9 +109,7 @@ namespace tr1
   _DEFINE_SPEC(0, __is_integral_helper, char, true)
   _DEFINE_SPEC(0, __is_integral_helper, signed char, true)
   _DEFINE_SPEC(0, __is_integral_helper, unsigned char, true)
-#ifdef _GLIBCXX_USE_WCHAR_T
   _DEFINE_SPEC(0, __is_integral_helper, wchar_t, true)
-#endif
   _DEFINE_SPEC(0, __is_integral_helper, short, true)
   _DEFINE_SPEC(0, __is_integral_helper, unsigned short, true)
   _DEFINE_SPEC(0, __is_integral_helper, int, true)
-- 
2.31.1


  parent reply	other threads:[~2021-10-09  0:13 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-09  0:13 [committed 1/8] libstdc++: Add missing _GLIBCXX_USE_WCHAR_T checks in testsuite Jonathan Wakely
2021-10-09  0:13 ` [PATCH 2/8] libstdc++: Move test that depends on wchar_t I/O to wchar_t sub-directory Jonathan Wakely
2021-10-09  0:13 ` [PATCH 3/8] libstdc++: Always define typedefs and hash functions for wide strings [PR 98725] Jonathan Wakely
2021-10-09  0:13 ` [PATCH 4/8] libstdc++: Enable vstring for wchar_t unconditionally [PR98725] Jonathan Wakely
2021-10-09  0:13 ` Jonathan Wakely [this message]
2021-10-09  0:13 ` [PATCH 6/8] libstdc++: Define std::wstring_convert unconditionally [PR 98725] Jonathan Wakely
2021-10-09  0:13 ` [PATCH 7/8] libstdc++: Define deleted wchar_t overloads " Jonathan Wakely
2021-10-09  0:13 ` [PATCH 8/8] libstdc++: Remove unnecessary uses of _GLIBCXX_USE_WCHAR_T in testsuite [PR98725] Jonathan Wakely

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=20211009001351.659647-5-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).