From b69ddbc62838f23ace237c206676b1ed1c882638 Mon Sep 17 00:00:00 2001 From: Nikolas Klauser Date: Wed, 13 Nov 2024 11:57:16 +0100 Subject: [PATCH] [libc++] Make variables in templates inline (#115785) The variables are all `constexpr`, which implies `inline`. Since they aren't `constexpr` in C++03 they're also not `inline` there. Because of that we define them out-of-line currently. Instead we can use the C++17 extension of `inline` variables, which results in the same weak definitions of the variables but without having all the boilerplate. --- .../include/__random/discard_block_engine.h | 10 +- .../__random/linear_congruential_engine.h | 24 +- .../__random/mersenne_twister_engine.h | 351 +----------------- .../include/__random/shuffle_order_engine.h | 5 +- .../__random/subtract_with_carry_engine.h | 21 +- .../include/__type_traits/integral_constant.h | 5 +- libcxx/include/any | 2 - libcxx/include/limits | 93 ++--- libcxx/include/ratio | 10 +- libcxx/src/chrono.cpp | 6 + libcxx/src/filesystem/filesystem_clock.cpp | 3 + libcxx/src/filesystem/path.cpp | 3 + libcxxabi/src/cxa_demangle.cpp | 4 - runtimes/cmake/Modules/WarningFlags.cmake | 1 + 14 files changed, 64 insertions(+), 474 deletions(-) diff --git a/libcxx/include/__random/discard_block_engine.h b/libcxx/include/__random/discard_block_engine.h index f319557a5736..45951245a534 100644 --- a/libcxx/include/__random/discard_block_engine.h +++ b/libcxx/include/__random/discard_block_engine.h @@ -43,8 +43,8 @@ public: typedef typename _Engine::result_type result_type; // engine characteristics - static _LIBCPP_CONSTEXPR const size_t block_size = __p; - static _LIBCPP_CONSTEXPR const size_t used_block = __r; + static inline _LIBCPP_CONSTEXPR const size_t block_size = __p; + static inline _LIBCPP_CONSTEXPR const size_t used_block = __r; #ifdef _LIBCPP_CXX03_LANG static const result_type _Min = _Engine::_Min; @@ -110,12 +110,6 @@ public: operator>>(basic_istream<_CharT, _Traits>& __is, discard_block_engine<_Eng, _Pp, _Rp>& __x); }; -template -_LIBCPP_CONSTEXPR const size_t discard_block_engine<_Engine, __p, __r>::block_size; - -template -_LIBCPP_CONSTEXPR const size_t discard_block_engine<_Engine, __p, __r>::used_block; - template typename discard_block_engine<_Engine, __p, __r>::result_type discard_block_engine<_Engine, __p, __r>::operator()() { if (__n_ >= static_cast(__r)) { diff --git a/libcxx/include/__random/linear_congruential_engine.h b/libcxx/include/__random/linear_congruential_engine.h index a0afda4945cd..a6e63839d3fc 100644 --- a/libcxx/include/__random/linear_congruential_engine.h +++ b/libcxx/include/__random/linear_congruential_engine.h @@ -251,12 +251,12 @@ public: static_assert(_Min < _Max, "linear_congruential_engine invalid parameters"); // engine characteristics - static _LIBCPP_CONSTEXPR const result_type multiplier = __a; - static _LIBCPP_CONSTEXPR const result_type increment = __c; - static _LIBCPP_CONSTEXPR const result_type modulus = __m; + static inline _LIBCPP_CONSTEXPR const result_type multiplier = __a; + static inline _LIBCPP_CONSTEXPR const result_type increment = __c; + static inline _LIBCPP_CONSTEXPR const result_type modulus = __m; _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR result_type min() { return _Min; } _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR result_type max() { return _Max; } - static _LIBCPP_CONSTEXPR const result_type default_seed = 1u; + static inline _LIBCPP_CONSTEXPR const result_type default_seed = 1u; // constructors and seeding functions #ifndef _LIBCPP_CXX03_LANG @@ -318,22 +318,6 @@ private: operator>>(basic_istream<_CharT, _Traits>& __is, linear_congruential_engine<_Up, _Ap, _Cp, _Np>& __x); }; -template -_LIBCPP_CONSTEXPR const typename linear_congruential_engine<_UIntType, __a, __c, __m>::result_type - linear_congruential_engine<_UIntType, __a, __c, __m>::multiplier; - -template -_LIBCPP_CONSTEXPR const typename linear_congruential_engine<_UIntType, __a, __c, __m>::result_type - linear_congruential_engine<_UIntType, __a, __c, __m>::increment; - -template -_LIBCPP_CONSTEXPR const typename linear_congruential_engine<_UIntType, __a, __c, __m>::result_type - linear_congruential_engine<_UIntType, __a, __c, __m>::modulus; - -template -_LIBCPP_CONSTEXPR const typename linear_congruential_engine<_UIntType, __a, __c, __m>::result_type - linear_congruential_engine<_UIntType, __a, __c, __m>::default_seed; - template template void linear_congruential_engine<_UIntType, __a, __c, __m>::__seed(_Sseq& __q, integral_constant) { diff --git a/libcxx/include/__random/mersenne_twister_engine.h b/libcxx/include/__random/mersenne_twister_engine.h index 9dd87f9ce71a..a23feffff0c8 100644 --- a/libcxx/include/__random/mersenne_twister_engine.h +++ b/libcxx/include/__random/mersenne_twister_engine.h @@ -166,22 +166,22 @@ public: static_assert(__f <= _Max, "mersenne_twister_engine invalid parameters"); // engine characteristics - static _LIBCPP_CONSTEXPR const size_t word_size = __w; - static _LIBCPP_CONSTEXPR const size_t state_size = __n; - static _LIBCPP_CONSTEXPR const size_t shift_size = __m; - static _LIBCPP_CONSTEXPR const size_t mask_bits = __r; - static _LIBCPP_CONSTEXPR const result_type xor_mask = __a; - static _LIBCPP_CONSTEXPR const size_t tempering_u = __u; - static _LIBCPP_CONSTEXPR const result_type tempering_d = __d; - static _LIBCPP_CONSTEXPR const size_t tempering_s = __s; - static _LIBCPP_CONSTEXPR const result_type tempering_b = __b; - static _LIBCPP_CONSTEXPR const size_t tempering_t = __t; - static _LIBCPP_CONSTEXPR const result_type tempering_c = __c; - static _LIBCPP_CONSTEXPR const size_t tempering_l = __l; - static _LIBCPP_CONSTEXPR const result_type initialization_multiplier = __f; + static inline _LIBCPP_CONSTEXPR const size_t word_size = __w; + static inline _LIBCPP_CONSTEXPR const size_t state_size = __n; + static inline _LIBCPP_CONSTEXPR const size_t shift_size = __m; + static inline _LIBCPP_CONSTEXPR const size_t mask_bits = __r; + static inline _LIBCPP_CONSTEXPR const result_type xor_mask = __a; + static inline _LIBCPP_CONSTEXPR const size_t tempering_u = __u; + static inline _LIBCPP_CONSTEXPR const result_type tempering_d = __d; + static inline _LIBCPP_CONSTEXPR const size_t tempering_s = __s; + static inline _LIBCPP_CONSTEXPR const result_type tempering_b = __b; + static inline _LIBCPP_CONSTEXPR const size_t tempering_t = __t; + static inline _LIBCPP_CONSTEXPR const result_type tempering_c = __c; + static inline _LIBCPP_CONSTEXPR const size_t tempering_l = __l; + static inline _LIBCPP_CONSTEXPR const result_type initialization_multiplier = __f; _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR result_type min() { return _Min; } _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR result_type max() { return _Max; } - static _LIBCPP_CONSTEXPR const result_type default_seed = 5489u; + static inline _LIBCPP_CONSTEXPR const result_type default_seed = 5489u; // constructors and seeding functions #ifndef _LIBCPP_CXX03_LANG @@ -310,329 +310,6 @@ private: } }; -template -_LIBCPP_CONSTEXPR const size_t - mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::word_size; - -template -_LIBCPP_CONSTEXPR const size_t - mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::state_size; - -template -_LIBCPP_CONSTEXPR const size_t - mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::shift_size; - -template -_LIBCPP_CONSTEXPR const size_t - mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::mask_bits; - -template -_LIBCPP_CONSTEXPR const typename mersenne_twister_engine< - _UIntType, - __w, - __n, - __m, - __r, - __a, - __u, - __d, - __s, - __b, - __t, - __c, - __l, - __f>::result_type - mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::xor_mask; - -template -_LIBCPP_CONSTEXPR const size_t - mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::tempering_u; - -template -_LIBCPP_CONSTEXPR const typename mersenne_twister_engine< - _UIntType, - __w, - __n, - __m, - __r, - __a, - __u, - __d, - __s, - __b, - __t, - __c, - __l, - __f>::result_type - mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::tempering_d; - -template -_LIBCPP_CONSTEXPR const size_t - mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::tempering_s; - -template -_LIBCPP_CONSTEXPR const typename mersenne_twister_engine< - _UIntType, - __w, - __n, - __m, - __r, - __a, - __u, - __d, - __s, - __b, - __t, - __c, - __l, - __f>::result_type - mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::tempering_b; - -template -_LIBCPP_CONSTEXPR const size_t - mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::tempering_t; - -template -_LIBCPP_CONSTEXPR const typename mersenne_twister_engine< - _UIntType, - __w, - __n, - __m, - __r, - __a, - __u, - __d, - __s, - __b, - __t, - __c, - __l, - __f>::result_type - mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::tempering_c; - -template -_LIBCPP_CONSTEXPR const size_t - mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::tempering_l; - -template -_LIBCPP_CONSTEXPR const typename mersenne_twister_engine< - _UIntType, - __w, - __n, - __m, - __r, - __a, - __u, - __d, - __s, - __b, - __t, - __c, - __l, - __f>::result_type - mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>:: - initialization_multiplier; - -template -_LIBCPP_CONSTEXPR const typename mersenne_twister_engine< - _UIntType, - __w, - __n, - __m, - __r, - __a, - __u, - __d, - __s, - __b, - __t, - __c, - __l, - __f>::result_type - mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::default_seed; - template -_LIBCPP_CONSTEXPR const size_t shuffle_order_engine<_Engine, __k>::table_size; - template _LIBCPP_HIDE_FROM_ABI bool operator==(const shuffle_order_engine<_Eng, _Kp>& __x, const shuffle_order_engine<_Eng, _Kp>& __y) { diff --git a/libcxx/include/__random/subtract_with_carry_engine.h b/libcxx/include/__random/subtract_with_carry_engine.h index e087ab4a3c2c..40dfaf4016ad 100644 --- a/libcxx/include/__random/subtract_with_carry_engine.h +++ b/libcxx/include/__random/subtract_with_carry_engine.h @@ -72,12 +72,12 @@ public: static_assert(_Min < _Max, "subtract_with_carry_engine invalid parameters"); // engine characteristics - static _LIBCPP_CONSTEXPR const size_t word_size = __w; - static _LIBCPP_CONSTEXPR const size_t short_lag = __s; - static _LIBCPP_CONSTEXPR const size_t long_lag = __r; + static inline _LIBCPP_CONSTEXPR const size_t word_size = __w; + static inline _LIBCPP_CONSTEXPR const size_t short_lag = __s; + static inline _LIBCPP_CONSTEXPR const size_t long_lag = __r; _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR result_type min() { return _Min; } _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR result_type max() { return _Max; } - static _LIBCPP_CONSTEXPR const result_type default_seed = 19780503u; + static inline _LIBCPP_CONSTEXPR const result_type default_seed = 19780503u; // constructors and seeding functions #ifndef _LIBCPP_CXX03_LANG @@ -130,19 +130,6 @@ private: _LIBCPP_HIDE_FROM_ABI void __seed(_Sseq& __q, integral_constant); }; -template -_LIBCPP_CONSTEXPR const size_t subtract_with_carry_engine<_UIntType, __w, __s, __r>::word_size; - -template -_LIBCPP_CONSTEXPR const size_t subtract_with_carry_engine<_UIntType, __w, __s, __r>::short_lag; - -template -_LIBCPP_CONSTEXPR const size_t subtract_with_carry_engine<_UIntType, __w, __s, __r>::long_lag; - -template -_LIBCPP_CONSTEXPR const typename subtract_with_carry_engine<_UIntType, __w, __s, __r>::result_type - subtract_with_carry_engine<_UIntType, __w, __s, __r>::default_seed; - template void subtract_with_carry_engine<_UIntType, __w, __s, __r>::seed(result_type __sd, integral_constant) { linear_congruential_engine __e(__sd == 0u ? default_seed : __sd); diff --git a/libcxx/include/__type_traits/integral_constant.h b/libcxx/include/__type_traits/integral_constant.h index 23e87e27feff..b8c75c546aa9 100644 --- a/libcxx/include/__type_traits/integral_constant.h +++ b/libcxx/include/__type_traits/integral_constant.h @@ -19,7 +19,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD template struct _LIBCPP_TEMPLATE_VIS integral_constant { - static _LIBCPP_CONSTEXPR const _Tp value = __v; + static inline _LIBCPP_CONSTEXPR const _Tp value = __v; typedef _Tp value_type; typedef integral_constant type; _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR operator value_type() const _NOEXCEPT { return value; } @@ -28,9 +28,6 @@ struct _LIBCPP_TEMPLATE_VIS integral_constant { #endif }; -template -_LIBCPP_CONSTEXPR const _Tp integral_constant<_Tp, __v>::value; - typedef integral_constant true_type; typedef integral_constant false_type; diff --git a/libcxx/include/any b/libcxx/include/any index 719dc2cf999e..cae56fa376e0 100644 --- a/libcxx/include/any +++ b/libcxx/include/any @@ -166,8 +166,6 @@ template struct _LIBCPP_TEMPLATE_VIS __unique_typeinfo { static constexpr int __id = 0; }; -template -constexpr int __unique_typeinfo<_Tp>::__id; template inline _LIBCPP_HIDE_FROM_ABI constexpr const void* __get_fallback_typeid() { diff --git a/libcxx/include/limits b/libcxx/include/limits index b85c66257d27..da0a92d7daff 100644 --- a/libcxx/include/limits +++ b/libcxx/include/limits @@ -464,18 +464,18 @@ class _LIBCPP_TEMPLATE_VIS numeric_limits : private __libcpp_numeric_limits<_Tp> typedef typename __base::type type; public: - static _LIBCPP_CONSTEXPR const bool is_specialized = __base::is_specialized; + static inline _LIBCPP_CONSTEXPR const bool is_specialized = __base::is_specialized; [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type min() _NOEXCEPT { return __base::min(); } [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type max() _NOEXCEPT { return __base::max(); } [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT { return __base::lowest(); } - static _LIBCPP_CONSTEXPR const int digits = __base::digits; - static _LIBCPP_CONSTEXPR const int digits10 = __base::digits10; - static _LIBCPP_CONSTEXPR const int max_digits10 = __base::max_digits10; - static _LIBCPP_CONSTEXPR const bool is_signed = __base::is_signed; - static _LIBCPP_CONSTEXPR const bool is_integer = __base::is_integer; - static _LIBCPP_CONSTEXPR const bool is_exact = __base::is_exact; - static _LIBCPP_CONSTEXPR const int radix = __base::radix; + static inline _LIBCPP_CONSTEXPR const int digits = __base::digits; + static inline _LIBCPP_CONSTEXPR const int digits10 = __base::digits10; + static inline _LIBCPP_CONSTEXPR const int max_digits10 = __base::max_digits10; + static inline _LIBCPP_CONSTEXPR const bool is_signed = __base::is_signed; + static inline _LIBCPP_CONSTEXPR const bool is_integer = __base::is_integer; + static inline _LIBCPP_CONSTEXPR const bool is_exact = __base::is_exact; + static inline _LIBCPP_CONSTEXPR const int radix = __base::radix; [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT { return __base::epsilon(); } @@ -483,17 +483,17 @@ public: return __base::round_error(); } - static _LIBCPP_CONSTEXPR const int min_exponent = __base::min_exponent; - static _LIBCPP_CONSTEXPR const int min_exponent10 = __base::min_exponent10; - static _LIBCPP_CONSTEXPR const int max_exponent = __base::max_exponent; - static _LIBCPP_CONSTEXPR const int max_exponent10 = __base::max_exponent10; + static inline _LIBCPP_CONSTEXPR const int min_exponent = __base::min_exponent; + static inline _LIBCPP_CONSTEXPR const int min_exponent10 = __base::min_exponent10; + static inline _LIBCPP_CONSTEXPR const int max_exponent = __base::max_exponent; + static inline _LIBCPP_CONSTEXPR const int max_exponent10 = __base::max_exponent10; - static _LIBCPP_CONSTEXPR const bool has_infinity = __base::has_infinity; - static _LIBCPP_CONSTEXPR const bool has_quiet_NaN = __base::has_quiet_NaN; - static _LIBCPP_CONSTEXPR const bool has_signaling_NaN = __base::has_signaling_NaN; + static inline _LIBCPP_CONSTEXPR const bool has_infinity = __base::has_infinity; + static inline _LIBCPP_CONSTEXPR const bool has_quiet_NaN = __base::has_quiet_NaN; + static inline _LIBCPP_CONSTEXPR const bool has_signaling_NaN = __base::has_signaling_NaN; _LIBCPP_SUPPRESS_DEPRECATED_PUSH - static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = __base::has_denorm; - static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const bool has_denorm_loss = __base::has_denorm_loss; + static inline _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = __base::has_denorm; + static inline _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const bool has_denorm_loss = __base::has_denorm_loss; _LIBCPP_SUPPRESS_DEPRECATED_POP [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT { return __base::infinity(); @@ -508,62 +508,15 @@ public: return __base::denorm_min(); } - static _LIBCPP_CONSTEXPR const bool is_iec559 = __base::is_iec559; - static _LIBCPP_CONSTEXPR const bool is_bounded = __base::is_bounded; - static _LIBCPP_CONSTEXPR const bool is_modulo = __base::is_modulo; + static inline _LIBCPP_CONSTEXPR const bool is_iec559 = __base::is_iec559; + static inline _LIBCPP_CONSTEXPR const bool is_bounded = __base::is_bounded; + static inline _LIBCPP_CONSTEXPR const bool is_modulo = __base::is_modulo; - static _LIBCPP_CONSTEXPR const bool traps = __base::traps; - static _LIBCPP_CONSTEXPR const bool tinyness_before = __base::tinyness_before; - static _LIBCPP_CONSTEXPR const float_round_style round_style = __base::round_style; + static inline _LIBCPP_CONSTEXPR const bool traps = __base::traps; + static inline _LIBCPP_CONSTEXPR const bool tinyness_before = __base::tinyness_before; + static inline _LIBCPP_CONSTEXPR const float_round_style round_style = __base::round_style; }; -template -_LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::is_specialized; -template -_LIBCPP_CONSTEXPR const int numeric_limits<_Tp>::digits; -template -_LIBCPP_CONSTEXPR const int numeric_limits<_Tp>::digits10; -template -_LIBCPP_CONSTEXPR const int numeric_limits<_Tp>::max_digits10; -template -_LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::is_signed; -template -_LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::is_integer; -template -_LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::is_exact; -template -_LIBCPP_CONSTEXPR const int numeric_limits<_Tp>::radix; -template -_LIBCPP_CONSTEXPR const int numeric_limits<_Tp>::min_exponent; -template -_LIBCPP_CONSTEXPR const int numeric_limits<_Tp>::min_exponent10; -template -_LIBCPP_CONSTEXPR const int numeric_limits<_Tp>::max_exponent; -template -_LIBCPP_CONSTEXPR const int numeric_limits<_Tp>::max_exponent10; -template -_LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::has_infinity; -template -_LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::has_quiet_NaN; -template -_LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::has_signaling_NaN; -template -_LIBCPP_CONSTEXPR const float_denorm_style numeric_limits<_Tp>::has_denorm; -template -_LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::has_denorm_loss; -template -_LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::is_iec559; -template -_LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::is_bounded; -template -_LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::is_modulo; -template -_LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::traps; -template -_LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::tinyness_before; -template -_LIBCPP_CONSTEXPR const float_round_style numeric_limits<_Tp>::round_style; - template class _LIBCPP_TEMPLATE_VIS numeric_limits : public numeric_limits<_Tp> {}; diff --git a/libcxx/include/ratio b/libcxx/include/ratio index 2009ad0367ec..7600e7c57ad7 100644 --- a/libcxx/include/ratio +++ b/libcxx/include/ratio @@ -236,18 +236,12 @@ class _LIBCPP_TEMPLATE_VIS ratio { static _LIBCPP_CONSTEXPR const intmax_t __gcd = __static_gcd<__na, __da>; public: - static _LIBCPP_CONSTEXPR const intmax_t num = __s * __na / __gcd; - static _LIBCPP_CONSTEXPR const intmax_t den = __da / __gcd; + static inline _LIBCPP_CONSTEXPR const intmax_t num = __s * __na / __gcd; + static inline _LIBCPP_CONSTEXPR const intmax_t den = __da / __gcd; typedef ratio type; }; -template -_LIBCPP_CONSTEXPR const intmax_t ratio<_Num, _Den>::num; - -template -_LIBCPP_CONSTEXPR const intmax_t ratio<_Num, _Den>::den; - template inline const bool __is_ratio_v = false; diff --git a/libcxx/src/chrono.cpp b/libcxx/src/chrono.cpp index f17ea5542bd9..098b6a171c88 100644 --- a/libcxx/src/chrono.cpp +++ b/libcxx/src/chrono.cpp @@ -134,7 +134,10 @@ static system_clock::time_point __libcpp_system_clock_now() { #endif +_LIBCPP_DIAGNOSTIC_PUSH +_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wdeprecated") const bool system_clock::is_steady; +_LIBCPP_DIAGNOSTIC_POP system_clock::time_point system_clock::now() noexcept { return __libcpp_system_clock_now(); } @@ -226,7 +229,10 @@ static steady_clock::time_point __libcpp_steady_clock_now() { # error "Monotonic clock not implemented on this platform" # endif +_LIBCPP_DIAGNOSTIC_PUSH +_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wdeprecated") const bool steady_clock::is_steady; +_LIBCPP_DIAGNOSTIC_POP steady_clock::time_point steady_clock::now() noexcept { return __libcpp_steady_clock_now(); } diff --git a/libcxx/src/filesystem/filesystem_clock.cpp b/libcxx/src/filesystem/filesystem_clock.cpp index 473a54a00f01..e4cfb9e72845 100644 --- a/libcxx/src/filesystem/filesystem_clock.cpp +++ b/libcxx/src/filesystem/filesystem_clock.cpp @@ -36,7 +36,10 @@ _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM +_LIBCPP_DIAGNOSTIC_PUSH +_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wdeprecated") const bool _FilesystemClock::is_steady; +_LIBCPP_DIAGNOSTIC_POP _FilesystemClock::time_point _FilesystemClock::now() noexcept { typedef chrono::duration __secs; diff --git a/libcxx/src/filesystem/path.cpp b/libcxx/src/filesystem/path.cpp index 58742442bae6..9f7dc54fdf15 100644 --- a/libcxx/src/filesystem/path.cpp +++ b/libcxx/src/filesystem/path.cpp @@ -24,7 +24,10 @@ using parser::string_view_t; // path definitions /////////////////////////////////////////////////////////////////////////////// +_LIBCPP_DIAGNOSTIC_PUSH +_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wdeprecated") constexpr path::value_type path::preferred_separator; +_LIBCPP_DIAGNOSTIC_POP path& path::replace_extension(path const& replacement) { path p = extension(); diff --git a/libcxxabi/src/cxa_demangle.cpp b/libcxxabi/src/cxa_demangle.cpp index bece33a007fc..4756d8343630 100644 --- a/libcxxabi/src/cxa_demangle.cpp +++ b/libcxxabi/src/cxa_demangle.cpp @@ -28,10 +28,6 @@ using namespace itanium_demangle; -constexpr const char *itanium_demangle::FloatData::spec; -constexpr const char *itanium_demangle::FloatData::spec; -constexpr const char *itanium_demangle::FloatData::spec; - // := _ # when number < 10 // := __ _ # when number >= 10 // extension := decimal-digit+ # at the end of string diff --git a/runtimes/cmake/Modules/WarningFlags.cmake b/runtimes/cmake/Modules/WarningFlags.cmake index 90edf3a95743..d17bf92389d0 100644 --- a/runtimes/cmake/Modules/WarningFlags.cmake +++ b/runtimes/cmake/Modules/WarningFlags.cmake @@ -24,6 +24,7 @@ function(cxx_add_warning_flags target enable_werror enable_pedantic) -Wunused-template -Wformat-nonliteral -Wzero-length-array + -Wdeprecated-redundant-constexpr-static-def ) if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")