Skip to content

Commit 4111721

Browse files
committed
[libc++] Drop -Wno-user-defined-literals when running the test suite
I'd like to reduce the number of warnings we disable when running the test suite, and these two seem like obvious targets for removal since it's really easy to just guard the "offending" code with pragmas.
1 parent baf41d2 commit 4111721

File tree

6 files changed

+38
-4
lines changed

6 files changed

+38
-4
lines changed

libcxx/include/__chrono/duration.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,10 @@ operator%(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2
481481
inline namespace literals {
482482
inline namespace chrono_literals {
483483

484+
_LIBCPP_DIAGNOSTIC_PUSH
485+
_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wuser-defined-literals")
486+
_LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wliteral-suffix")
487+
484488
_LIBCPP_HIDE_FROM_ABI constexpr chrono::hours operator""h(unsigned long long __h) {
485489
return chrono::hours(static_cast<chrono::hours::rep>(__h));
486490
}
@@ -529,6 +533,8 @@ _LIBCPP_HIDE_FROM_ABI constexpr chrono::duration<long double, nano> operator""ns
529533
return chrono::duration<long double, nano>(__ns);
530534
}
531535

536+
_LIBCPP_DIAGNOSTIC_POP
537+
532538
} // namespace chrono_literals
533539
} // namespace literals
534540

libcxx/include/__chrono/literals.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,21 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2424

2525
inline namespace literals {
2626
inline namespace chrono_literals {
27+
28+
_LIBCPP_DIAGNOSTIC_PUSH
29+
_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wuser-defined-literals")
30+
_LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wliteral-suffix")
31+
2732
_LIBCPP_HIDE_FROM_ABI constexpr chrono::day operator""d(unsigned long long __d) noexcept {
2833
return chrono::day(static_cast<unsigned>(__d));
2934
}
3035

3136
_LIBCPP_HIDE_FROM_ABI constexpr chrono::year operator""y(unsigned long long __y) noexcept {
3237
return chrono::year(static_cast<int>(__y));
3338
}
39+
40+
_LIBCPP_DIAGNOSTIC_POP
41+
3442
} // namespace chrono_literals
3543
} // namespace literals
3644

libcxx/include/complex

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1443,6 +1443,11 @@ _LIBCPP_HIDE_FROM_ABI constexpr const _Xp&& get(const complex<_Xp>&& __z) noexce
14431443
// Literal suffix for complex number literals [complex.literals]
14441444
inline namespace literals {
14451445
inline namespace complex_literals {
1446+
1447+
_LIBCPP_DIAGNOSTIC_PUSH
1448+
_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wuser-defined-literals")
1449+
_LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wliteral-suffix")
1450+
14461451
_LIBCPP_HIDE_FROM_ABI inline constexpr complex<long double> operator""il(long double __im) { return {0.0l, __im}; }
14471452

14481453
_LIBCPP_HIDE_FROM_ABI inline constexpr complex<long double> operator""il(unsigned long long __im) {
@@ -1464,6 +1469,9 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr complex<float> operator""if(long double _
14641469
_LIBCPP_HIDE_FROM_ABI inline constexpr complex<float> operator""if(unsigned long long __im) {
14651470
return {0.0f, static_cast<float>(__im)};
14661471
}
1472+
1473+
_LIBCPP_DIAGNOSTIC_POP
1474+
14671475
} // namespace complex_literals
14681476
} // namespace literals
14691477
# endif

libcxx/include/string

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3946,6 +3946,11 @@ erase_if(basic_string<_CharT, _Traits, _Allocator>& __str, _Predicate __pred) {
39463946
// Literal suffixes for basic_string [basic.string.literals]
39473947
inline namespace literals {
39483948
inline namespace string_literals {
3949+
3950+
_LIBCPP_DIAGNOSTIC_PUSH
3951+
_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wuser-defined-literals")
3952+
_LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wliteral-suffix")
3953+
39493954
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<char>
39503955
operator""s(const char* __str, size_t __len) {
39513956
return basic_string<char>(__str, __len);
@@ -3973,6 +3978,9 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<char32_t
39733978
operator""s(const char32_t* __str, size_t __len) {
39743979
return basic_string<char32_t>(__str, __len);
39753980
}
3981+
3982+
_LIBCPP_DIAGNOSTIC_POP
3983+
39763984
} // namespace string_literals
39773985
} // namespace literals
39783986

libcxx/include/string_view

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -924,6 +924,11 @@ struct hash<basic_string_view<wchar_t, char_traits<wchar_t> > > : __string_view_
924924
# if _LIBCPP_STD_VER >= 14
925925
inline namespace literals {
926926
inline namespace string_view_literals {
927+
928+
_LIBCPP_DIAGNOSTIC_PUSH
929+
_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wuser-defined-literals")
930+
_LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wliteral-suffix")
931+
927932
inline _LIBCPP_HIDE_FROM_ABI constexpr basic_string_view<char> operator""sv(const char* __str, size_t __len) noexcept {
928933
return basic_string_view<char>(__str, __len);
929934
}
@@ -951,6 +956,9 @@ inline _LIBCPP_HIDE_FROM_ABI constexpr basic_string_view<char32_t>
951956
operator""sv(const char32_t* __str, size_t __len) noexcept {
952957
return basic_string_view<char32_t>(__str, __len);
953958
}
959+
960+
_LIBCPP_DIAGNOSTIC_POP
961+
954962
} // namespace string_view_literals
955963
} // namespace literals
956964
# endif

libcxx/utils/libcxx/test/params.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,6 @@
3535
# GCC warns about places where we might want to add sized allocation/deallocation
3636
# functions, but we know better what we're doing/testing in the test suite.
3737
"-Wno-sized-deallocation",
38-
# Turn off warnings about user-defined literals with reserved suffixes. Those are
39-
# just noise since we are testing the Standard Library itself.
40-
"-Wno-literal-suffix", # GCC
41-
"-Wno-user-defined-literals", # Clang
4238
# GCC warns about this when TEST_IS_CONSTANT_EVALUATED is used on a non-constexpr
4339
# function. (This mostly happens in C++11 mode.)
4440
# TODO(mordante) investigate a solution for this issue.

0 commit comments

Comments
 (0)