diff --git a/libcxx/include/__chrono/duration.h b/libcxx/include/__chrono/duration.h index 57fa64d650068..270bad253c139 100644 --- a/libcxx/include/__chrono/duration.h +++ b/libcxx/include/__chrono/duration.h @@ -481,6 +481,10 @@ operator%(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2 inline namespace literals { inline namespace chrono_literals { +_LIBCPP_DIAGNOSTIC_PUSH +_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wuser-defined-literals") +_LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wliteral-suffix") + _LIBCPP_HIDE_FROM_ABI constexpr chrono::hours operator""h(unsigned long long __h) { return chrono::hours(static_cast(__h)); } @@ -529,6 +533,8 @@ _LIBCPP_HIDE_FROM_ABI constexpr chrono::duration operator""ns return chrono::duration(__ns); } +_LIBCPP_DIAGNOSTIC_POP + } // namespace chrono_literals } // namespace literals diff --git a/libcxx/include/__chrono/literals.h b/libcxx/include/__chrono/literals.h index 89800440edf43..2268c38676d31 100644 --- a/libcxx/include/__chrono/literals.h +++ b/libcxx/include/__chrono/literals.h @@ -24,6 +24,11 @@ _LIBCPP_BEGIN_NAMESPACE_STD inline namespace literals { inline namespace chrono_literals { + +_LIBCPP_DIAGNOSTIC_PUSH +_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wuser-defined-literals") +_LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wliteral-suffix") + _LIBCPP_HIDE_FROM_ABI constexpr chrono::day operator""d(unsigned long long __d) noexcept { return chrono::day(static_cast(__d)); } @@ -31,6 +36,9 @@ _LIBCPP_HIDE_FROM_ABI constexpr chrono::day operator""d(unsigned long long __d) _LIBCPP_HIDE_FROM_ABI constexpr chrono::year operator""y(unsigned long long __y) noexcept { return chrono::year(static_cast(__y)); } + +_LIBCPP_DIAGNOSTIC_POP + } // namespace chrono_literals } // namespace literals diff --git a/libcxx/include/complex b/libcxx/include/complex index d8ec3d95c10ed..1550bc81f1626 100644 --- a/libcxx/include/complex +++ b/libcxx/include/complex @@ -1443,6 +1443,11 @@ _LIBCPP_HIDE_FROM_ABI constexpr const _Xp&& get(const complex<_Xp>&& __z) noexce // Literal suffix for complex number literals [complex.literals] inline namespace literals { inline namespace complex_literals { + +_LIBCPP_DIAGNOSTIC_PUSH +_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wuser-defined-literals") +_LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wliteral-suffix") + _LIBCPP_HIDE_FROM_ABI inline constexpr complex operator""il(long double __im) { return {0.0l, __im}; } _LIBCPP_HIDE_FROM_ABI inline constexpr complex operator""il(unsigned long long __im) { @@ -1464,6 +1469,9 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr complex operator""if(long double _ _LIBCPP_HIDE_FROM_ABI inline constexpr complex operator""if(unsigned long long __im) { return {0.0f, static_cast(__im)}; } + +_LIBCPP_DIAGNOSTIC_POP + } // namespace complex_literals } // namespace literals # endif diff --git a/libcxx/include/string b/libcxx/include/string index ede42467b99fe..f1083cf624792 100644 --- a/libcxx/include/string +++ b/libcxx/include/string @@ -3946,6 +3946,11 @@ erase_if(basic_string<_CharT, _Traits, _Allocator>& __str, _Predicate __pred) { // Literal suffixes for basic_string [basic.string.literals] inline namespace literals { inline namespace string_literals { + +_LIBCPP_DIAGNOSTIC_PUSH +_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wuser-defined-literals") +_LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wliteral-suffix") + inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string operator""s(const char* __str, size_t __len) { return basic_string(__str, __len); @@ -3973,6 +3978,9 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(__str, __len); } + +_LIBCPP_DIAGNOSTIC_POP + } // namespace string_literals } // namespace literals diff --git a/libcxx/include/string_view b/libcxx/include/string_view index 5ecaa3de7deba..5a55cc92b5897 100644 --- a/libcxx/include/string_view +++ b/libcxx/include/string_view @@ -924,6 +924,11 @@ struct hash > > : __string_view_ # if _LIBCPP_STD_VER >= 14 inline namespace literals { inline namespace string_view_literals { + +_LIBCPP_DIAGNOSTIC_PUSH +_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wuser-defined-literals") +_LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wliteral-suffix") + inline _LIBCPP_HIDE_FROM_ABI constexpr basic_string_view operator""sv(const char* __str, size_t __len) noexcept { return basic_string_view(__str, __len); } @@ -951,6 +956,9 @@ inline _LIBCPP_HIDE_FROM_ABI constexpr basic_string_view operator""sv(const char32_t* __str, size_t __len) noexcept { return basic_string_view(__str, __len); } + +_LIBCPP_DIAGNOSTIC_POP + } // namespace string_view_literals } // namespace literals # endif diff --git a/libcxx/utils/libcxx/test/params.py b/libcxx/utils/libcxx/test/params.py index c02d6df1c47a4..44578ebe0e582 100644 --- a/libcxx/utils/libcxx/test/params.py +++ b/libcxx/utils/libcxx/test/params.py @@ -35,10 +35,6 @@ # GCC warns about places where we might want to add sized allocation/deallocation # functions, but we know better what we're doing/testing in the test suite. "-Wno-sized-deallocation", - # Turn off warnings about user-defined literals with reserved suffixes. Those are - # just noise since we are testing the Standard Library itself. - "-Wno-literal-suffix", # GCC - "-Wno-user-defined-literals", # Clang # GCC warns about this when TEST_IS_CONSTANT_EVALUATED is used on a non-constexpr # function. (This mostly happens in C++11 mode.) # TODO(mordante) investigate a solution for this issue.