From: Jonathan Wakely Date: Thu, 26 Jul 2018 14:02:01 +0000 (+0100) Subject: Remove char16_t and char32_t dependency on X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=612c9c702e2c9ebf0058d659d57371605c2e0020;p=gcc.git Remove char16_t and char32_t dependency on The char16_t and char32_t types are automatically defined by the compiler and do not depend on support in . The char_traits specializations depend on uint_leastNN_t but can be made to work anyway by using the predefined macros, or as a last resort make_unsigned. * include/bits/basic_string.h [!_GLIBCXX_USE_C99_STDINT_TR1] (hash, hash): Remove dependency on _GLIBCXX_USE_C99_STDINT_TR1. * include/bits/char_traits.h [!_GLIBCXX_USE_C99_STDINT_TR1] (char_traits, char_traits): Remove dependency on _GLIBCXX_USE_C99_STDINT_TR1. Use __UINT_LEAST16_TYPE__ and __UINT_LEAST32_TYPE__ or make_unsigned when is not usable. * include/bits/codecvt.h [!_GLIBCXX_USE_C99_STDINT_TR1] (codecvt) (codecvt) (codecvt_byname) (codecvt_byname): Remove dependency on _GLIBCXX_USE_C99_STDINT_TR1. * include/bits/locale_facets.h [!_GLIBCXX_USE_C99_STDINT_TR1] (_GLIBCXX_NUM_UNICODE_FACETS): Likewise. * include/bits/stringfwd.h [!_GLIBCXX_USE_C99_STDINT_TR1] (char_traits, char_traits) (basic_string, basic_string): Remove dependency on _GLIBCXX_USE_C99_STDINT_TR1. * include/experimental/string_view [!_GLIBCXX_USE_C99_STDINT_TR1] (u16string_view, u32string_view, hash) (hash, operator""sv(const char16_t, size_t)) (operator""sv(const char32_t, size_t)): Likewise. * include/ext/vstring.h [!_GLIBCXX_USE_C99_STDINT_TR1] (hash<__u16vstring>, hash<__u32vstring>): Likewise. * include/ext/vstring_fwd.h [!_GLIBCXX_USE_C99_STDINT_TR1] (__u16vstring, __u16sso_string, __u16rc_string, __u32vstring) (__u32sso_string, __u32rc_string): Likewise. * include/std/codecvt [!_GLIBCXX_USE_C99_STDINT_TR1] (codecvt_mode) (codecvt_utf8, codecvt_utf16, codecvt_utf8_utf16): Likewise. * include/std/string_view [!_GLIBCXX_USE_C99_STDINT_TR1] (u16string_view, u32string_view, hash) (hash, operator""sv(const char16_t, size_t)) (operator""sv(const char32_t, size_t)): Likewise. * src/c++11/codecvt.cc: Likewise. * src/c++98/locale_init.cc: Likewise. * src/c++98/localename.cc: Likewise. From-SVN: r263002 --- diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index a3665ee8b6a..10b1496af81 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,5 +1,43 @@ 2018-07-26 Jonathan Wakely + * include/bits/basic_string.h [!_GLIBCXX_USE_C99_STDINT_TR1] + (hash, hash): Remove dependency on + _GLIBCXX_USE_C99_STDINT_TR1. + * include/bits/char_traits.h [!_GLIBCXX_USE_C99_STDINT_TR1] + (char_traits, char_traits): Remove dependency on + _GLIBCXX_USE_C99_STDINT_TR1. Use __UINT_LEAST16_TYPE__ and + __UINT_LEAST32_TYPE__ or make_unsigned when is not usable. + * include/bits/codecvt.h [!_GLIBCXX_USE_C99_STDINT_TR1] + (codecvt) + (codecvt) + (codecvt_byname) + (codecvt_byname): Remove dependency + on _GLIBCXX_USE_C99_STDINT_TR1. + * include/bits/locale_facets.h [!_GLIBCXX_USE_C99_STDINT_TR1] + (_GLIBCXX_NUM_UNICODE_FACETS): Likewise. + * include/bits/stringfwd.h [!_GLIBCXX_USE_C99_STDINT_TR1] + (char_traits, char_traits) + (basic_string, basic_string): Remove dependency + on _GLIBCXX_USE_C99_STDINT_TR1. + * include/experimental/string_view [!_GLIBCXX_USE_C99_STDINT_TR1] + (u16string_view, u32string_view, hash) + (hash, operator""sv(const char16_t, size_t)) + (operator""sv(const char32_t, size_t)): Likewise. + * include/ext/vstring.h [!_GLIBCXX_USE_C99_STDINT_TR1] + (hash<__u16vstring>, hash<__u32vstring>): Likewise. + * include/ext/vstring_fwd.h [!_GLIBCXX_USE_C99_STDINT_TR1] + (__u16vstring, __u16sso_string, __u16rc_string, __u32vstring) + (__u32sso_string, __u32rc_string): Likewise. + * include/std/codecvt [!_GLIBCXX_USE_C99_STDINT_TR1] (codecvt_mode) + (codecvt_utf8, codecvt_utf16, codecvt_utf8_utf16): Likewise. + * include/std/string_view [!_GLIBCXX_USE_C99_STDINT_TR1] + (u16string_view, u32string_view, hash) + (hash, operator""sv(const char16_t, size_t)) + (operator""sv(const char32_t, size_t)): Likewise. + * src/c++11/codecvt.cc: Likewise. + * src/c++98/locale_init.cc: Likewise. + * src/c++98/localename.cc: Likewise. + * include/bits/atomic_futex.h [!_GLIBCXX_USE_C99_STDINT_TR1] (__atomic_futex_unsigned_base): Remove dependency on _GLIBCXX_USE_C99_STDINT_TR1 macro. diff --git a/libstdc++-v3/include/bits/basic_string.h b/libstdc++-v3/include/bits/basic_string.h index 2d1b9dc6c29..c9463989ddc 100644 --- a/libstdc++-v3/include/bits/basic_string.h +++ b/libstdc++-v3/include/bits/basic_string.h @@ -6662,7 +6662,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION #endif #endif /* _GLIBCXX_COMPATIBILITY_CXX0X */ -#ifdef _GLIBCXX_USE_C99_STDINT_TR1 /// std::hash specialization for u16string. template<> struct hash @@ -6692,7 +6691,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template<> struct __is_fast_hash> : std::false_type { }; -#endif #if __cplusplus > 201103L @@ -6716,7 +6714,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { return basic_string{__str, __len}; } #endif -#ifdef _GLIBCXX_USE_C99_STDINT_TR1 _GLIBCXX_DEFAULT_ABI_TAG inline basic_string operator""s(const char16_t* __str, size_t __len) @@ -6726,7 +6723,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION inline basic_string operator""s(const char32_t* __str, size_t __len) { return basic_string{__str, __len}; } -#endif #pragma GCC diagnostic pop } // inline namespace string_literals diff --git a/libstdc++-v3/include/bits/char_traits.h b/libstdc++-v3/include/bits/char_traits.h index 7cc7c74e8fe..63e810715f8 100644 --- a/libstdc++-v3/include/bits/char_traits.h +++ b/libstdc++-v3/include/bits/char_traits.h @@ -41,7 +41,7 @@ #include // For WEOF, wmemmove, wmemset, etc. #ifndef _GLIBCXX_ALWAYS_INLINE -#define _GLIBCXX_ALWAYS_INLINE inline __attribute__((__always_inline__)) +# define _GLIBCXX_ALWAYS_INLINE inline __attribute__((__always_inline__)) #endif namespace __gnu_cxx _GLIBCXX_VISIBILITY(default) @@ -495,8 +495,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _GLIBCXX_END_NAMESPACE_VERSION } // namespace -#if ((__cplusplus >= 201103L) \ - && defined(_GLIBCXX_USE_C99_STDINT_TR1)) +#if __cplusplus >= 201103L #include @@ -508,7 +507,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION struct char_traits { typedef char16_t char_type; +#ifdef _GLIBCXX_USE_C99_STDINT_TR1 typedef uint_least16_t int_type; +#elif defined __UINT_LEAST16_TYPE__ + typedef __UINT_LEAST16_TYPE__ int_type; +#else + typedef make_unsigned::type int_type; +#endif typedef streamoff off_type; typedef u16streampos pos_type; typedef mbstate_t state_type; @@ -605,7 +610,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION struct char_traits { typedef char32_t char_type; +#ifdef _GLIBCXX_USE_C99_STDINT_TR1 typedef uint_least32_t int_type; +#elif defined __UINT_LEAST32_TYPE__ + typedef __UINT_LEAST32_TYPE__ int_type; +#else + typedef make_unsigned::type int_type; +#endif typedef streamoff off_type; typedef u32streampos pos_type; typedef mbstate_t state_type; @@ -701,6 +712,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _GLIBCXX_END_NAMESPACE_VERSION } // namespace -#endif +#endif // C++11 #endif // _CHAR_TRAITS_H diff --git a/libstdc++-v3/include/bits/codecvt.h b/libstdc++-v3/include/bits/codecvt.h index b61df0a7e22..bafa28c3a00 100644 --- a/libstdc++-v3/include/bits/codecvt.h +++ b/libstdc++-v3/include/bits/codecvt.h @@ -459,7 +459,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION #endif //_GLIBCXX_USE_WCHAR_T #if __cplusplus >= 201103L -#ifdef _GLIBCXX_USE_C99_STDINT_TR1 /** @brief Class codecvt specialization. * * Converts between UTF-16 and UTF-8. @@ -574,7 +573,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION do_max_length() const throw(); }; -#endif // _GLIBCXX_USE_C99_STDINT_TR1 #endif // C++11 /// class codecvt_byname [22.2.1.6]. @@ -605,7 +603,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ~codecvt_byname() { } }; -#if __cplusplus >= 201103L && defined(_GLIBCXX_USE_C99_STDINT_TR1) +#if __cplusplus >= 201103L template<> class codecvt_byname : public codecvt @@ -641,7 +639,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION virtual ~codecvt_byname() { } }; -#endif +#endif // C++11 // Inhibit implicit instantiations for required instantiations, // which are defined via explicit instantiations elsewhere. @@ -668,7 +666,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION has_facet >(const locale&); #endif -#if __cplusplus >= 201103L && defined(_GLIBCXX_USE_C99_STDINT_TR1) +#if __cplusplus >= 201103L extern template class codecvt_byname; extern template class codecvt_byname; #endif diff --git a/libstdc++-v3/include/bits/locale_facets.h b/libstdc++-v3/include/bits/locale_facets.h index 7bce42232bb..f6e0283fec9 100644 --- a/libstdc++-v3/include/bits/locale_facets.h +++ b/libstdc++-v3/include/bits/locale_facets.h @@ -59,11 +59,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION # define _GLIBCXX_NUM_FACETS 14 # define _GLIBCXX_NUM_CXX11_FACETS 8 #endif -#ifdef _GLIBCXX_USE_C99_STDINT_TR1 -# define _GLIBCXX_NUM_UNICODE_FACETS 2 -#else -# define _GLIBCXX_NUM_UNICODE_FACETS 0 -#endif +#define _GLIBCXX_NUM_UNICODE_FACETS 2 // Convert string to numeric value of type _Tp and store results. // NB: This is specialized for all required types, there is no diff --git a/libstdc++-v3/include/bits/stringfwd.h b/libstdc++-v3/include/bits/stringfwd.h index cf39dbfe048..15eb7183633 100644 --- a/libstdc++-v3/include/bits/stringfwd.h +++ b/libstdc++-v3/include/bits/stringfwd.h @@ -58,8 +58,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template<> struct char_traits; #endif -#if ((__cplusplus >= 201103L) \ - && defined(_GLIBCXX_USE_C99_STDINT_TR1)) +#if __cplusplus >= 201103L template<> struct char_traits; template<> struct char_traits; #endif @@ -78,8 +77,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 typedef basic_string wstring; #endif -#if ((__cplusplus >= 201103L) \ - && defined(_GLIBCXX_USE_C99_STDINT_TR1)) +#if __cplusplus >= 201103L /// A string of @c char16_t typedef basic_string u16string; diff --git a/libstdc++-v3/include/experimental/string_view b/libstdc++-v3/include/experimental/string_view index e42d5acde78..b3bc1a9fb4f 100644 --- a/libstdc++-v3/include/experimental/string_view +++ b/libstdc++-v3/include/experimental/string_view @@ -566,10 +566,8 @@ inline namespace fundamentals_v1 #ifdef _GLIBCXX_USE_WCHAR_T using wstring_view = basic_string_view; #endif -#ifdef _GLIBCXX_USE_C99_STDINT_TR1 using u16string_view = basic_string_view; using u32string_view = basic_string_view; -#endif } // namespace fundamentals_v1 } // namespace experimental @@ -607,7 +605,6 @@ inline namespace fundamentals_v1 { }; #endif -#ifdef _GLIBCXX_USE_C99_STDINT_TR1 template<> struct hash : public __hash_base @@ -635,7 +632,6 @@ inline namespace fundamentals_v1 template<> struct __is_fast_hash> : std::false_type { }; -#endif namespace experimental { @@ -656,7 +652,6 @@ namespace experimental { return basic_string_view{__str, __len}; } #endif -#ifdef _GLIBCXX_USE_C99_STDINT_TR1 inline constexpr basic_string_view operator""sv(const char16_t* __str, size_t __len) noexcept { return basic_string_view{__str, __len}; } @@ -664,7 +659,6 @@ namespace experimental inline constexpr basic_string_view operator""sv(const char32_t* __str, size_t __len) noexcept { return basic_string_view{__str, __len}; } -#endif #pragma GCC diagnostic pop } // namespace string_literals } // namespace literals diff --git a/libstdc++-v3/include/ext/vstring.h b/libstdc++-v3/include/ext/vstring.h index 605311e9a28..246684d555f 100644 --- a/libstdc++-v3/include/ext/vstring.h +++ b/libstdc++-v3/include/ext/vstring.h @@ -2933,7 +2933,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION }; #endif -#ifdef _GLIBCXX_USE_C99_STDINT_TR1 /// std::hash specialization for __u16vstring. template<> struct hash<__gnu_cxx::__u16vstring> @@ -2955,7 +2954,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { return std::_Hash_impl::hash(__s.data(), __s.length() * sizeof(char32_t)); } }; -#endif _GLIBCXX_END_NAMESPACE_VERSION } // namespace diff --git a/libstdc++-v3/include/ext/vstring_fwd.h b/libstdc++-v3/include/ext/vstring_fwd.h index 7ca79981e3b..f2e6b4bdfa7 100644 --- a/libstdc++-v3/include/ext/vstring_fwd.h +++ b/libstdc++-v3/include/ext/vstring_fwd.h @@ -66,9 +66,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION std::allocator, __rc_string_base> __wrc_string; #endif -#if ((__cplusplus >= 201103L) \ - && defined(_GLIBCXX_USE_C99_STDINT_TR1)) - +#if __cplusplus >= 201103L typedef __versa_string __u16vstring; typedef __u16vstring __u16sso_string; typedef @@ -80,8 +78,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION typedef __versa_string, std::allocator, __rc_string_base> __u32rc_string; - -#endif +#endif // C++11 _GLIBCXX_END_NAMESPACE_VERSION } // namespace diff --git a/libstdc++-v3/include/std/codecvt b/libstdc++-v3/include/std/codecvt index 2a1bcdb6672..f765c674d78 100644 --- a/libstdc++-v3/include/std/codecvt +++ b/libstdc++-v3/include/std/codecvt @@ -40,8 +40,6 @@ #include #include -#ifdef _GLIBCXX_USE_C99_STDINT_TR1 - namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION @@ -174,8 +172,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _GLIBCXX_END_NAMESPACE_VERSION } // namespace -#endif // _GLIBCXX_USE_C99_STDINT_TR1 - -#endif +#endif // C++11 #endif /* _GLIBCXX_CODECVT */ diff --git a/libstdc++-v3/include/std/string_view b/libstdc++-v3/include/std/string_view index f84664ca286..9e0f6a723e4 100644 --- a/libstdc++-v3/include/std/string_view +++ b/libstdc++-v3/include/std/string_view @@ -555,10 +555,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION #ifdef _GLIBCXX_USE_WCHAR_T using wstring_view = basic_string_view; #endif -#ifdef _GLIBCXX_USE_C99_STDINT_TR1 + using u16string_view = basic_string_view; using u32string_view = basic_string_view; -#endif // [string.view.hash], hash support: @@ -594,7 +593,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { }; #endif -#ifdef _GLIBCXX_USE_C99_STDINT_TR1 template<> struct hash : public __hash_base @@ -622,7 +620,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template<> struct __is_fast_hash> : std::false_type { }; -#endif inline namespace literals { @@ -640,7 +637,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { return basic_string_view{__str, __len}; } #endif -#ifdef _GLIBCXX_USE_C99_STDINT_TR1 inline constexpr basic_string_view operator""sv(const char16_t* __str, size_t __len) noexcept { return basic_string_view{__str, __len}; } @@ -648,7 +644,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION inline constexpr basic_string_view operator""sv(const char32_t* __str, size_t __len) noexcept { return basic_string_view{__str, __len}; } -#endif + #pragma GCC diagnostic pop } // namespace string_literals } // namespace literals diff --git a/libstdc++-v3/src/c++11/codecvt.cc b/libstdc++-v3/src/c++11/codecvt.cc index 3a1a825070c..503f2fe1ff3 100644 --- a/libstdc++-v3/src/c++11/codecvt.cc +++ b/libstdc++-v3/src/c++11/codecvt.cc @@ -26,7 +26,6 @@ #include // std::memcpy, std::memcmp #include // std::min -#ifdef _GLIBCXX_USE_C99_STDINT_TR1 namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION @@ -1639,4 +1638,3 @@ template class codecvt_byname; _GLIBCXX_END_NAMESPACE_VERSION } -#endif // _GLIBCXX_USE_C99_STDINT_TR1 diff --git a/libstdc++-v3/src/c++98/locale_init.cc b/libstdc++-v3/src/c++98/locale_init.cc index fb3d8ab972a..5651c04b9ed 100644 --- a/libstdc++-v3/src/c++98/locale_init.cc +++ b/libstdc++-v3/src/c++98/locale_init.cc @@ -201,7 +201,6 @@ namespace fake_messages_w messages_w; #endif -#ifdef _GLIBCXX_USE_C99_STDINT_TR1 typedef char fake_codecvt_c16[sizeof(codecvt)] __attribute__ ((aligned(__alignof__(codecvt)))); fake_codecvt_c16 codecvt_c16; @@ -209,7 +208,6 @@ namespace typedef char fake_codecvt_c32[sizeof(codecvt)] __attribute__ ((aligned(__alignof__(codecvt)))); fake_codecvt_c32 codecvt_c32; -#endif // Storage for "C" locale caches. typedef char fake_num_cache_c[sizeof(std::__numpunct_cache)] @@ -329,7 +327,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION &std::ctype::id, &codecvt::id, #endif -#ifdef _GLIBCXX_USE_C99_STDINT_TR1 +#if _GLIBCXX_NUM_UNICODE_FACETS != 0 &codecvt::id, &codecvt::id, #endif @@ -536,7 +534,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _M_init_facet(new (&messages_w) std::messages(1)); #endif -#ifdef _GLIBCXX_USE_C99_STDINT_TR1 +#ifdef _GLIBCXX_NUM_UNICODE_FACETS != 0 _M_init_facet(new (&codecvt_c16) codecvt(1)); _M_init_facet(new (&codecvt_c32) codecvt(1)); #endif diff --git a/libstdc++-v3/src/c++98/localename.cc b/libstdc++-v3/src/c++98/localename.cc index 7723f6afbe8..afb43e5cea9 100644 --- a/libstdc++-v3/src/c++98/localename.cc +++ b/libstdc++-v3/src/c++98/localename.cc @@ -269,7 +269,7 @@ const int num_facets = _GLIBCXX_NUM_FACETS + _GLIBCXX_NUM_UNICODE_FACETS _M_init_facet(new std::messages(__cloc, __s)); #endif -#ifdef _GLIBCXX_USE_C99_STDINT_TR1 +#if _GLIBCXX_NUM_UNICODE_FACETS != 0 _M_init_facet(new codecvt); _M_init_facet(new codecvt); #endif