From f8bd64f3dbc6d8e7bc00e06d798c3ec25d60f6b2 Mon Sep 17 00:00:00 2001 From: "Stephan T. Lavavej" Date: Tue, 20 Jul 2021 21:25:30 -0700 Subject: [PATCH 01/14] Remove unused `__DOUBLE_EXPONENT_BITS`/`__FLOAT_EXPONENT_BITS`. --- stl/inc/xcharconv_ryu.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/stl/inc/xcharconv_ryu.h b/stl/inc/xcharconv_ryu.h index 282e18dc1b..d4f7ca635d 100644 --- a/stl/inc/xcharconv_ryu.h +++ b/stl/inc/xcharconv_ryu.h @@ -134,7 +134,6 @@ _NODISCARD inline uint64_t __double_to_bits(const double __d) { // vvvvvvvvvv DERIVED FROM d2s.h vvvvvvvvvv inline constexpr int __DOUBLE_MANTISSA_BITS = 52; -inline constexpr int __DOUBLE_EXPONENT_BITS = 11; inline constexpr int __DOUBLE_BIAS = 1023; inline constexpr int __DOUBLE_POW5_INV_BITCOUNT = 122; @@ -950,7 +949,6 @@ _NODISCARD inline to_chars_result __d2exp_buffered_n(char* _First, char* const _ // vvvvvvvvvv DERIVED FROM f2s.c vvvvvvvvvv inline constexpr int __FLOAT_MANTISSA_BITS = 23; -inline constexpr int __FLOAT_EXPONENT_BITS = 8; inline constexpr int __FLOAT_BIAS = 127; // This table is generated by PrintFloatLookupTable. From dbf1b0c18eb3d6498c978257d50b132b71a4b1b3 Mon Sep 17 00:00:00 2001 From: "Stephan T. Lavavej" Date: Wed, 21 Jul 2021 18:22:21 -0700 Subject: [PATCH 02/14] We can directly include Windows.h now. --- tests/std/include/test_death.hpp | 2 +- tests/std/include/test_thread_support.hpp | 2 +- tests/std/include/test_windows.hpp | 6 ------ tests/std/tests/Dev08_563686_ostream/test.cpp | 2 +- tests/std/tests/Dev09_056375_locale_cleanup/test.cpp | 2 +- tests/std/tests/Dev09_056375_locale_cleanup/testdll.cpp | 2 +- .../tests/Dev11_0493504_error_category_lifetime/test.cpp | 2 +- .../test.cpp | 2 +- tests/std/tests/VSO_0226079_mutex/test.cpp | 2 +- .../tests/VSO_0744055_atomic_load_8_bytes_readonly/test.cpp | 2 +- 10 files changed, 9 insertions(+), 15 deletions(-) delete mode 100644 tests/std/include/test_windows.hpp diff --git a/tests/std/include/test_death.hpp b/tests/std/include/test_death.hpp index 296a0f6901..521945a24b 100644 --- a/tests/std/include/test_death.hpp +++ b/tests/std/include/test_death.hpp @@ -9,7 +9,7 @@ #include #include -#include +#include namespace std_testing { constexpr int internal_failure = 103; diff --git a/tests/std/include/test_thread_support.hpp b/tests/std/include/test_thread_support.hpp index 322612a93b..3f51384ddd 100644 --- a/tests/std/include/test_thread_support.hpp +++ b/tests/std/include/test_thread_support.hpp @@ -10,7 +10,7 @@ #include #include #ifdef _MSC_EXTENSIONS -#include +#include #endif // _MSC_EXTENSIONS class one_shot { diff --git a/tests/std/include/test_windows.hpp b/tests/std/include/test_windows.hpp deleted file mode 100644 index aecb1ac36b..0000000000 --- a/tests/std/include/test_windows.hpp +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -#pragma once -struct IUnknown; // windows.h drags in a template that uses IUnknown before it has been declared. -#include diff --git a/tests/std/tests/Dev08_563686_ostream/test.cpp b/tests/std/tests/Dev08_563686_ostream/test.cpp index ffaf75ef30..1b5d8b4bd4 100644 --- a/tests/std/tests/Dev08_563686_ostream/test.cpp +++ b/tests/std/tests/Dev08_563686_ostream/test.cpp @@ -29,7 +29,7 @@ #include #include -#include +#include int main() { // Track CRT blocks diff --git a/tests/std/tests/Dev09_056375_locale_cleanup/test.cpp b/tests/std/tests/Dev09_056375_locale_cleanup/test.cpp index d34c7618fe..b495ef5fd1 100644 --- a/tests/std/tests/Dev09_056375_locale_cleanup/test.cpp +++ b/tests/std/tests/Dev09_056375_locale_cleanup/test.cpp @@ -5,7 +5,7 @@ #include #include -#include +#include using namespace std; diff --git a/tests/std/tests/Dev09_056375_locale_cleanup/testdll.cpp b/tests/std/tests/Dev09_056375_locale_cleanup/testdll.cpp index 93ecade706..c0301b3020 100644 --- a/tests/std/tests/Dev09_056375_locale_cleanup/testdll.cpp +++ b/tests/std/tests/Dev09_056375_locale_cleanup/testdll.cpp @@ -4,7 +4,7 @@ #include #include -#include +#include using namespace std; diff --git a/tests/std/tests/Dev11_0493504_error_category_lifetime/test.cpp b/tests/std/tests/Dev11_0493504_error_category_lifetime/test.cpp index 9971297225..5d219e233d 100644 --- a/tests/std/tests/Dev11_0493504_error_category_lifetime/test.cpp +++ b/tests/std/tests/Dev11_0493504_error_category_lifetime/test.cpp @@ -10,7 +10,7 @@ #include #endif // _M_CEE -#include +#include using namespace std; diff --git a/tests/std/tests/VSO_0121275_filesystem_canonical_should_handle_many_double_dots/test.cpp b/tests/std/tests/VSO_0121275_filesystem_canonical_should_handle_many_double_dots/test.cpp index f6878463eb..0e1e96bb23 100644 --- a/tests/std/tests/VSO_0121275_filesystem_canonical_should_handle_many_double_dots/test.cpp +++ b/tests/std/tests/VSO_0121275_filesystem_canonical_should_handle_many_double_dots/test.cpp @@ -12,7 +12,7 @@ #include #include -#include +#include using namespace std; namespace fs = std::experimental::filesystem; diff --git a/tests/std/tests/VSO_0226079_mutex/test.cpp b/tests/std/tests/VSO_0226079_mutex/test.cpp index cb071ec84f..e065a472f8 100644 --- a/tests/std/tests/VSO_0226079_mutex/test.cpp +++ b/tests/std/tests/VSO_0226079_mutex/test.cpp @@ -13,7 +13,7 @@ #include #include -#include +#include using namespace std; using namespace std::chrono; diff --git a/tests/std/tests/VSO_0744055_atomic_load_8_bytes_readonly/test.cpp b/tests/std/tests/VSO_0744055_atomic_load_8_bytes_readonly/test.cpp index 4e633d7753..352e6a7fc6 100644 --- a/tests/std/tests/VSO_0744055_atomic_load_8_bytes_readonly/test.cpp +++ b/tests/std/tests/VSO_0744055_atomic_load_8_bytes_readonly/test.cpp @@ -5,7 +5,7 @@ #include #include -#include +#include int main() { // A customer wanted to read a std::atomic from a read-only memory-mapped file. From b087a334895ddcc6efa5c79b65839c0cb809629b Mon Sep 17 00:00:00 2001 From: "Stephan T. Lavavej" Date: Wed, 21 Jul 2021 21:22:11 -0700 Subject: [PATCH 03/14] Change `typename CharT` to `class CharT`. --- stl/src/fiopen.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stl/src/fiopen.cpp b/stl/src/fiopen.cpp index da9b536320..d304f37e08 100644 --- a/stl/src/fiopen.cpp +++ b/stl/src/fiopen.cpp @@ -23,7 +23,7 @@ FILE* _Xfsopen(_In_z_ const wchar_t* filename, _In_ int mode, _In_ int prot) { return _wfsopen(filename, mods[mode], prot); } -template +template FILE* _Xfiopen(const CharT* filename, ios_base::openmode mode, int prot) { static const int valid[] = { // valid combinations of open flags From 0297b193078653fa993e01f2f5bbae20b27baff7 Mon Sep 17 00:00:00 2001 From: "Stephan T. Lavavej" Date: Wed, 21 Jul 2021 21:30:45 -0700 Subject: [PATCH 04/14] Stylistically reorder exception_ptr operators; provide only necessary ones for C++20. --- stl/inc/exception | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/stl/inc/exception b/stl/inc/exception index 483e71ff5c..0643e0be91 100644 --- a/stl/inc/exception +++ b/stl/inc/exception @@ -264,25 +264,27 @@ public: return __ExceptionPtrCompare(&_Lhs, &_Rhs); } - _NODISCARD friend bool operator==(nullptr_t, const exception_ptr& _Rhs) noexcept { - return !_Rhs; - } - _NODISCARD friend bool operator==(const exception_ptr& _Lhs, nullptr_t) noexcept { return !_Lhs; } +#if !_HAS_CXX20 + _NODISCARD friend bool operator==(nullptr_t, const exception_ptr& _Rhs) noexcept { + return !_Rhs; + } + _NODISCARD friend bool operator!=(const exception_ptr& _Lhs, const exception_ptr& _Rhs) noexcept { return !(_Lhs == _Rhs); } - _NODISCARD friend bool operator!=(nullptr_t _Lhs, const exception_ptr& _Rhs) noexcept { + _NODISCARD friend bool operator!=(const exception_ptr& _Lhs, nullptr_t _Rhs) noexcept { return !(_Lhs == _Rhs); } - _NODISCARD friend bool operator!=(const exception_ptr& _Lhs, nullptr_t _Rhs) noexcept { + _NODISCARD friend bool operator!=(nullptr_t _Lhs, const exception_ptr& _Rhs) noexcept { return !(_Lhs == _Rhs); } +#endif // !_HAS_CXX20 private: #ifdef __clang__ From b9ea785341f7afc2ca47725864869dd1cd5fcf15 Mon Sep 17 00:00:00 2001 From: "Stephan T. Lavavej" Date: Fri, 6 Aug 2021 15:48:12 -0700 Subject: [PATCH 05/14] Construct tags with empty braces. --- stl/inc/future | 10 +++++----- stl/inc/tuple | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/stl/inc/future b/stl/inc/future index c7568af6df..1eed675290 100644 --- a/stl/inc/future +++ b/stl/inc/future @@ -1157,7 +1157,7 @@ public: } _NODISCARD future<_Ty> get_future() { - return future<_Ty>(_MyPromise._Get_state_for_future(), _Nil()); + return future<_Ty>(_MyPromise._Get_state_for_future(), _Nil{}); } void set_value(const _Ty& _Val) { @@ -1219,7 +1219,7 @@ public: } _NODISCARD future<_Ty&> get_future() { - return future<_Ty&>(_MyPromise._Get_state_for_future(), _Nil()); + return future<_Ty&>(_MyPromise._Get_state_for_future(), _Nil{}); } void set_value(_Ty& _Val) { @@ -1273,7 +1273,7 @@ public: } _NODISCARD future get_future() { - return future(_MyPromise._Get_state_for_future(), _Nil()); + return future(_MyPromise._Get_state_for_future(), _Nil{}); } void set_value() { @@ -1365,7 +1365,7 @@ public: } _NODISCARD future<_Ret> get_future() { - return future<_Ret>(_MyPromise._Get_state_for_future(), _Nil()); + return future<_Ret>(_MyPromise._Get_state_for_future(), _Nil{}); } void operator()(_ArgTypes... _Args) { @@ -1494,7 +1494,7 @@ _NODISCARD future<_Invoke_result_t, decay_t<_ArgTypes>...>> async( _Get_associated_state<_Ret>(_Policy, _Fake_no_copy_callable_adapter<_Fty, _ArgTypes...>( _STD forward<_Fty>(_Fnarg), _STD forward<_ArgTypes>(_Args)...))); - return future<_Ret>(_Pr._Get_state_for_future(), _Nil()); + return future<_Ret>(_Pr._Get_state_for_future(), _Nil{}); } template diff --git a/stl/inc/tuple b/stl/inc/tuple index 8fae9205b5..180de03fbf 100644 --- a/stl/inc/tuple +++ b/stl/inc/tuple @@ -963,7 +963,7 @@ constexpr _Ret _Tuple_cat(index_sequence<_Kx...>, index_sequence<_Ix...>, _Ty&& template _NODISCARD constexpr typename _Tuple_cat1<_Tuples...>::type tuple_cat(_Tuples&&... _Tpls) { // concatenate tuples using _Cat1 = _Tuple_cat1<_Tuples...>; - return _Tuple_cat(typename _Cat1::_Kx_arg_seq(), typename _Cat1::_Ix_arg_seq(), + return _Tuple_cat(typename _Cat1::_Kx_arg_seq{}, typename _Cat1::_Ix_arg_seq{}, _STD forward_as_tuple(_STD forward<_Tuples>(_Tpls)...)); } From 563714a727427eee21a735c72777e8ae4b63b2b0 Mon Sep 17 00:00:00 2001 From: "Stephan T. Lavavej" Date: Fri, 6 Aug 2021 15:50:40 -0700 Subject: [PATCH 06/14] Capitalize template parameters. --- tests/std/tests/VSO_0226079_mutex/test.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/std/tests/VSO_0226079_mutex/test.cpp b/tests/std/tests/VSO_0226079_mutex/test.cpp index e065a472f8..c23eace460 100644 --- a/tests/std/tests/VSO_0226079_mutex/test.cpp +++ b/tests/std/tests/VSO_0226079_mutex/test.cpp @@ -339,10 +339,10 @@ struct mutex_test_fixture { } // nonstandard xtime type - template - xtime to_xtime(const chrono::duration& rel_time) { // convert duration to xtime + template + xtime to_xtime(const chrono::duration& rel_time) { // convert duration to xtime xtime xt; - if (rel_time <= chrono::duration::zero()) { // negative or zero relative time, return zero + if (rel_time <= chrono::duration::zero()) { // negative or zero relative time, return zero xt.sec = 0; xt.nsec = 0; } else { // positive relative time, convert From 0ed74f944b77bf66609a3a980ff0b28dfd953691 Mon Sep 17 00:00:00 2001 From: "Stephan T. Lavavej" Date: Fri, 6 Aug 2021 16:11:40 -0700 Subject: [PATCH 07/14] Change `size() == 0` to `empty()` for `string`s. --- stl/inc/cvt/wbuffer | 2 +- stl/inc/xlocmon | 6 +++--- stl/inc/xlocnum | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/stl/inc/cvt/wbuffer b/stl/inc/cvt/wbuffer index cea11d042b..150bc758ff 100644 --- a/stl/inc/cvt/wbuffer +++ b/stl/inc/cvt/wbuffer @@ -252,7 +252,7 @@ namespace stdext { if (_Mystrbuf && _Status != _Wrote) { // got buffer, haven't written, try to compose an element if (_Status != _Eof) { - if (_Str.size() == 0) { + if (_Str.empty()) { _Status = _Need; } else { _Status = _Got; diff --git a/stl/inc/xlocmon b/stl/inc/xlocmon index 3452c969ea..914e94bf30 100644 --- a/stl/inc/xlocmon +++ b/stl/inc/xlocmon @@ -360,7 +360,7 @@ protected: _State |= ios_base::eofbit; } - if (_Str.size() == 0) { + if (_Str.empty()) { _State |= ios_base::failbit; // _Getmfld failed } else { // convert to long double const char* _Eb = _Str.c_str(); @@ -476,7 +476,7 @@ private: int _Fracdigseen = 0; int _Fracdigits = _Ppunct_fac->frac_digits(); const string _Grouping = _Ppunct_fac->grouping(); - const _Elem _Kseparator = _Grouping.size() == 0 ? _Elem{} : _Ppunct_fac->thousands_sep(); + const _Elem _Kseparator = _Grouping.empty() ? _Elem{} : _Ppunct_fac->thousands_sep(); if (_Kseparator == _Elem{} || CHAR_MAX <= static_cast(*_Grouping.c_str())) { for (; _First != _Last && (_Idx = _Find_elem(_Atoms, *_First)) < 10; ++_First) { @@ -540,7 +540,7 @@ private: } } - if (_Val.size() == 0) { + if (_Val.empty()) { _Bad = true; // fail if no elements parsed } else { for (; _Fracdigseen < _Fracdigits; ++_Fracdigseen) { diff --git a/stl/inc/xlocnum b/stl/inc/xlocnum index 549b02ae8f..498ad09a30 100644 --- a/stl/inc/xlocnum +++ b/stl/inc/xlocnum @@ -656,7 +656,7 @@ private: const locale& _Loc) const { // get integer field from [_First, _Last) into _Ac const auto& _Punct_fac = _STD use_facet>(_Loc); const string _Grouping = _Punct_fac.grouping(); - const _Elem _Kseparator = _Grouping.size() == 0 ? _Elem{} : _Punct_fac.thousands_sep(); + const _Elem _Kseparator = _Grouping.empty() ? _Elem{} : _Punct_fac.thousands_sep(); constexpr int _Numget_signoff = 22; constexpr int _Numget_xoff = 24; @@ -812,7 +812,7 @@ private: } } } else { // grouping specified, gather digits and group sizes - const _Elem _Kseparator = _Grouping.size() == 0 ? _Elem{} : _Punct_fac.thousands_sep(); + const _Elem _Kseparator = _Grouping.empty() ? _Elem{} : _Punct_fac.thousands_sep(); string _Groups(1, '\0'); size_t _Group = 0; @@ -1003,7 +1003,7 @@ private: } } } else { // grouping specified, gather digits and group sizes - const _Elem _Kseparator = _Grouping.size() == 0 ? _Elem{} : _Punct_fac.thousands_sep(); + const _Elem _Kseparator = _Grouping.empty() ? _Elem{} : _Punct_fac.thousands_sep(); string _Groups(1, '\0'); size_t _Group = 0; From 6575910269a4617eec479169576a1238ff460145 Mon Sep 17 00:00:00 2001 From: "Stephan T. Lavavej" Date: Fri, 6 Aug 2021 16:15:05 -0700 Subject: [PATCH 08/14] Remove unnecessary parens in `(b.func) (b.data)`. --- stl/src/cthread.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stl/src/cthread.cpp b/stl/src/cthread.cpp index 9a032bb05d..d5923f5312 100644 --- a/stl/src/cthread.cpp +++ b/stl/src/cthread.cpp @@ -33,7 +33,7 @@ namespace { *b.started = 1; _Cnd_signal(*b.cond); _Mtx_unlock(*b.mtx); - const unsigned int res = (b.func) (b.data); + const unsigned int res = b.func(b.data); _Cnd_do_broadcast_at_thread_exit(); return res; } From 51ea5ae1105e86492cfe78443363b5c9961d8592 Mon Sep 17 00:00:00 2001 From: "Stephan T. Lavavej" Date: Fri, 6 Aug 2021 16:20:35 -0700 Subject: [PATCH 09/14] Avoid unnecessary `auto`. --- stl/inc/algorithm | 2 +- stl/inc/random | 2 +- stl/inc/xutility | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/stl/inc/algorithm b/stl/inc/algorithm index cb6147d51f..8bff4dfa87 100644 --- a/stl/inc/algorithm +++ b/stl/inc/algorithm @@ -41,7 +41,7 @@ _STD_BEGIN _INLINE_VAR constexpr int _ISORT_MAX = 32; // maximum size for insertion sort template -_INLINE_VAR constexpr auto _Isort_max = _Iter_diff_t<_It>{_ISORT_MAX}; +_INLINE_VAR constexpr _Iter_diff_t<_It> _Isort_max{_ISORT_MAX}; template constexpr ptrdiff_t _Temporary_buffer_size(const _Diff _Value) noexcept { diff --git a/stl/inc/random b/stl/inc/random index b0155d67a6..2ed8c68bb0 100644 --- a/stl/inc/random +++ b/stl/inc/random @@ -3011,7 +3011,7 @@ private: _LogSx = _STD log(_Sx) + static_cast<_Ty>(_ExpMax) * (_Ln2 * 2); } - const auto _Fx = _Ty{_STD sqrt(_Ty{-2} * _LogSx / _Sx)}; + const _Ty _Fx{_STD sqrt(_Ty{-2} * _LogSx / _Sx)}; if (_Keep) { // save second value for next call _Xx2 = _Fx * _Vx2; _Valid = true; diff --git a/stl/inc/xutility b/stl/inc/xutility index dc3f747c32..7da65d0906 100644 --- a/stl/inc/xutility +++ b/stl/inc/xutility @@ -1280,10 +1280,10 @@ struct _Distance_unknown { }; template -_INLINE_VAR constexpr auto _Max_possible_v = _Diff{static_cast>(-1) >> 1}; +_INLINE_VAR constexpr _Diff _Max_possible_v{static_cast>(-1) >> 1}; template -_INLINE_VAR constexpr auto _Min_possible_v = _Diff{-_Max_possible_v<_Diff> - 1}; +_INLINE_VAR constexpr _Diff _Min_possible_v{-_Max_possible_v<_Diff> - 1}; template _INLINE_VAR constexpr bool _Offset_verifiable_v = false; From 3cb7042566831757c622edb45f96abe356946d0c Mon Sep 17 00:00:00 2001 From: "Stephan T. Lavavej" Date: Mon, 16 Aug 2021 16:56:36 -0700 Subject: [PATCH 10/14] libcxx: Unskip C++23 tests (will be "unsupported" until GH 2001 is fixed). --- tests/libcxx/expected_results.txt | 11 +---------- tests/libcxx/skipped_tests.txt | 11 +---------- 2 files changed, 2 insertions(+), 20 deletions(-) diff --git a/tests/libcxx/expected_results.txt b/tests/libcxx/expected_results.txt index 39350ca0d9..e22989a766 100644 --- a/tests/libcxx/expected_results.txt +++ b/tests/libcxx/expected_results.txt @@ -275,16 +275,7 @@ std/utilities/memory/default.allocator/allocator.members/allocate.verify.cpp SKI # *** MISSING STL FEATURES *** -# C++23 P1048R1 "is_scoped_enum" -std/utilities/meta/meta.unary/meta.unary.prop/is_scoped_enum.pass.cpp FAIL - -# C++23 P1679R3 "contains() For basic_string/basic_string_view" -std/strings/basic.string/string.contains/contains.char.pass.cpp FAIL -std/strings/basic.string/string.contains/contains.ptr.pass.cpp FAIL -std/strings/basic.string/string.contains/contains.string_view.pass.cpp FAIL -std/strings/string.view/string.view.template/contains.char.pass.cpp FAIL -std/strings/string.view/string.view.template/contains.ptr.pass.cpp FAIL -std/strings/string.view/string.view.template/contains.string_view.pass.cpp FAIL +# Nothing here! :-) # *** MISSING COMPILER FEATURES *** diff --git a/tests/libcxx/skipped_tests.txt b/tests/libcxx/skipped_tests.txt index 3390cb1e8e..e0424d97bf 100644 --- a/tests/libcxx/skipped_tests.txt +++ b/tests/libcxx/skipped_tests.txt @@ -275,16 +275,7 @@ utilities\memory\default.allocator\allocator.members\allocate.verify.cpp # *** MISSING STL FEATURES *** -# C++23 P1048R1 "is_scoped_enum" -utilities\meta\meta.unary\meta.unary.prop\is_scoped_enum.pass.cpp - -# C++23 P1679R3 "contains() For basic_string/basic_string_view" -strings\basic.string\string.contains\contains.char.pass.cpp -strings\basic.string\string.contains\contains.ptr.pass.cpp -strings\basic.string\string.contains\contains.string_view.pass.cpp -strings\string.view\string.view.template\contains.char.pass.cpp -strings\string.view\string.view.template\contains.ptr.pass.cpp -strings\string.view\string.view.template\contains.string_view.pass.cpp +# Nothing here! :-) # *** MISSING COMPILER FEATURES *** From ac95e58a95873e51e8c4eb8c3eafa59b947deaad Mon Sep 17 00:00:00 2001 From: "Stephan T. Lavavej" Date: Tue, 17 Aug 2021 17:36:36 -0700 Subject: [PATCH 11/14] Emit an error when compiling stdatomic.h as C. --- stl/inc/stdatomic.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/stl/inc/stdatomic.h b/stl/inc/stdatomic.h index 462759021b..b36f35c5e3 100644 --- a/stl/inc/stdatomic.h +++ b/stl/inc/stdatomic.h @@ -9,6 +9,10 @@ #include #if _STL_COMPILER_PREPROCESSOR +#ifndef __cplusplus +#error is not yet supported when compiling as C, but this is planned for a future release. +#endif // __cplusplus + #ifdef _M_CEE_PURE #error is not supported when compiling with /clr:pure. #endif // _M_CEE_PURE From 2fa59f1fcf168d71aa9f3c25d9b98c1985d067f8 Mon Sep 17 00:00:00 2001 From: "Stephan T. Lavavej" Date: Tue, 17 Aug 2021 18:52:14 -0700 Subject: [PATCH 12/14] Simplify stoi(): int and long are the same size for us. --- stl/inc/string | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stl/inc/string b/stl/inc/string index 41cb4877fd..10d08c88f5 100644 --- a/stl/inc/string +++ b/stl/inc/string @@ -95,7 +95,7 @@ _NODISCARD inline int stoi(const string& _Str, size_t* _Idx = nullptr, int _Base _Xinvalid_argument("invalid stoi argument"); } - if (_Errno_ref == ERANGE || _Ans < INT_MIN || INT_MAX < _Ans) { + if (_Errno_ref == ERANGE) { _Xout_of_range("stoi argument out of range"); } @@ -276,7 +276,7 @@ _NODISCARD inline int stoi(const wstring& _Str, size_t* _Idx = nullptr, int _Bas _Xinvalid_argument("invalid stoi argument"); } - if (_Errno_ref == ERANGE || _Ans < INT_MIN || INT_MAX < _Ans) { + if (_Errno_ref == ERANGE) { _Xout_of_range("stoi argument out of range"); } From 959faf05dd13fdbbd0c93bdae2489f8dcb18aa65 Mon Sep 17 00:00:00 2001 From: "Stephan T. Lavavej" Date: Tue, 17 Aug 2021 19:23:47 -0700 Subject: [PATCH 13/14] Use deprecated attributes in experimental/coroutine (improves syntax highlighting). --- stl/inc/experimental/coroutine | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/stl/inc/experimental/coroutine b/stl/inc/experimental/coroutine index ed2b37665a..0508a76808 100644 --- a/stl/inc/experimental/coroutine +++ b/stl/inc/experimental/coroutine @@ -88,8 +88,9 @@ namespace experimental { return _Ptr; } - __declspec( - deprecated("is deprecated. Use coroutine_handle::address() instead")) void* to_address() const noexcept { + [[deprecated("coroutine_handle::to_address() is deprecated. " + "Use coroutine_handle::address() instead.")]] void* + to_address() const noexcept { return _Ptr; } @@ -131,8 +132,9 @@ namespace experimental { struct coroutine_handle : coroutine_handle<> { // general form using coroutine_handle<>::coroutine_handle; - __declspec(deprecated("with pointer parameter is deprecated. Use coroutine_handle::from_promise(T&) " - "instead")) static coroutine_handle from_promise(_PromiseT* _Prom) noexcept { + [[deprecated("coroutine_handle::from_promise(T*) with pointer parameter is deprecated. " + "Use coroutine_handle::from_promise(T&) instead.")]] static coroutine_handle + from_promise(_PromiseT* _Prom) noexcept { return from_promise(*_Prom); } From a30b6ff5381bbe61c9ce25ca17a2ded23d90a84b Mon Sep 17 00:00:00 2001 From: "Stephan T. Lavavej" Date: Tue, 17 Aug 2021 20:03:46 -0700 Subject: [PATCH 14/14] Demacroize xthreads.h size/alignment constants. --- stl/inc/xthreads.h | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/stl/inc/xthreads.h b/stl/inc/xthreads.h index c8c8880057..a1b8ee2bfe 100644 --- a/stl/inc/xthreads.h +++ b/stl/inc/xthreads.h @@ -28,27 +28,27 @@ struct _Thrd_t { // thread identifier for Win32 // Size and alignment for _Mtx_internal_imp_t and _Cnd_internal_imp_t #ifdef _CRT_WINDOWS #ifdef _WIN64 -#define _Mtx_internal_imp_size 32 -#define _Mtx_internal_imp_alignment 8 -#define _Cnd_internal_imp_size 16 -#define _Cnd_internal_imp_alignment 8 +_INLINE_VAR constexpr size_t _Mtx_internal_imp_size = 32; +_INLINE_VAR constexpr size_t _Mtx_internal_imp_alignment = 8; +_INLINE_VAR constexpr size_t _Cnd_internal_imp_size = 16; +_INLINE_VAR constexpr size_t _Cnd_internal_imp_alignment = 8; #else // _WIN64 -#define _Mtx_internal_imp_size 20 -#define _Mtx_internal_imp_alignment 4 -#define _Cnd_internal_imp_size 8 -#define _Cnd_internal_imp_alignment 4 +_INLINE_VAR constexpr size_t _Mtx_internal_imp_size = 20; +_INLINE_VAR constexpr size_t _Mtx_internal_imp_alignment = 4; +_INLINE_VAR constexpr size_t _Cnd_internal_imp_size = 8; +_INLINE_VAR constexpr size_t _Cnd_internal_imp_alignment = 4; #endif // _WIN64 #else // _CRT_WINDOWS #ifdef _WIN64 -#define _Mtx_internal_imp_size 80 -#define _Mtx_internal_imp_alignment 8 -#define _Cnd_internal_imp_size 72 -#define _Cnd_internal_imp_alignment 8 +_INLINE_VAR constexpr size_t _Mtx_internal_imp_size = 80; +_INLINE_VAR constexpr size_t _Mtx_internal_imp_alignment = 8; +_INLINE_VAR constexpr size_t _Cnd_internal_imp_size = 72; +_INLINE_VAR constexpr size_t _Cnd_internal_imp_alignment = 8; #else // _WIN64 -#define _Mtx_internal_imp_size 48 -#define _Mtx_internal_imp_alignment 4 -#define _Cnd_internal_imp_size 40 -#define _Cnd_internal_imp_alignment 4 +_INLINE_VAR constexpr size_t _Mtx_internal_imp_size = 48; +_INLINE_VAR constexpr size_t _Mtx_internal_imp_alignment = 4; +_INLINE_VAR constexpr size_t _Cnd_internal_imp_size = 40; +_INLINE_VAR constexpr size_t _Cnd_internal_imp_alignment = 4; #endif // _WIN64 #endif // _CRT_WINDOWS