Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable /clr C++20 support #3194

Merged
merged 38 commits into from
Nov 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
ae5c295
Enable product code for /clr.
StephanTLavavej Nov 6, 2022
ab1e924
Use _EmptyLockit for /clr:pure only.
StephanTLavavej Nov 6, 2022
51d84f4
Avoid warning LNK4248 for _Mtx_t/_Cnd_t.
StephanTLavavej Nov 6, 2022
8d3479f
Cleanup: Define _RELIABILITY_CONTRACT for _CRTBLD only. (Needed by xl…
StephanTLavavej Nov 6, 2022
5a68149
Replace native_matrix.lst with impure_matrix.lst.
StephanTLavavej Nov 6, 2022
bb1fa2f
Replace native_17_matrix.lst with usual_17_matrix.lst (has /clr but n…
StephanTLavavej Nov 6, 2022
529a9ee
Replace env_threads.lst with env_minus_pure.lst.
StephanTLavavej Nov 6, 2022
727bd09
Enable /clr coverage in tests.
StephanTLavavej Nov 6, 2022
e530571
Reported VSO-1658184 "/clr silent bad codegen with std::_Signed128 mu…
StephanTLavavej Nov 6, 2022
f5cb545
Reported VSO-1659383 '/clr atomic and thread emit error C2711 "this f…
StephanTLavavej Nov 6, 2022
711d646
Reported VSO-1659408 '/clr alignas emits error C2711 "this function c…
StephanTLavavej Nov 6, 2022
c0d4873
Reported VSO-1659496 "/clr emits bogus error C2079 "uses undefined st…
StephanTLavavej Nov 6, 2022
ca592df
Reported VSO-1659511 "/clr runtime hang when calling std::async in a …
StephanTLavavej Nov 6, 2022
b957153
Reported VSO-1659489 "/clr System.AccessViolationException with paral…
StephanTLavavej Nov 6, 2022
b59f951
Reported VSO-1659695 "/clr x86 runtime assertions/crashes with parall…
StephanTLavavej Nov 6, 2022
bbebb6e
Reported VSO-1663104 "/clr rejects the __ceilf/__floorf intrinsics wi…
StephanTLavavej Nov 6, 2022
3c94782
Upgrade test coverage from `/clr /std:c++17` to `/clr /std:c++20 /d1c…
StephanTLavavej Nov 6, 2022
8ac9b4a
Prepare by extracting /EHsc from C++20 matrices.
StephanTLavavej Nov 6, 2022
7a05c9a
Add `/clr /std:c++20 /d1clrcxxstd` to C++20 and coroutine matrices.
StephanTLavavej Nov 6, 2022
8c40741
Reported VSO-1663233 "/clr C++20 rejects <coroutine> with error C3861…
StephanTLavavej Nov 6, 2022
19ef4c7
Reported VSO-1663257 "/clr C++20 rejects P0428R2 Familiar template sy…
StephanTLavavej Nov 6, 2022
1707d9a
Reported VSO-1664293 "/clr C++20 chk assertion failed: rhs.is_lvalue(…
StephanTLavavej Nov 6, 2022
9fc07c8
Reported VSO-1664341 "/clr C++20 System.NullReferenceException when c…
StephanTLavavej Nov 6, 2022
7866c58
Reported VSO-1664382 "/clr C++20 emits bogus error C2127 "illegal ini…
StephanTLavavej Nov 6, 2022
9c395fe
Reported VSO-1664463 "/clr C++20 alignas emits error C3821 'managed t…
StephanTLavavej Nov 6, 2022
39a5764
Reported VSO-1665481 "/clr C++20 silent bad codegen for complex<float…
StephanTLavavej Nov 6, 2022
60d9f34
Reported VSO-1665606 "/clr C++20 backend ICE with counted_iterator's …
StephanTLavavej Nov 6, 2022
3655bd2
Reported VSO-1665654 "/clr C++20 System.AccessViolationException with…
StephanTLavavej Nov 6, 2022
ef54e46
Reported VSO-1665663 "/clr C++20 source_location has incorrect column…
StephanTLavavej Nov 6, 2022
07d500b
Reported VSO-1665670 "/clr C++20 incorrectly reports input_iterator e…
StephanTLavavej Nov 6, 2022
bb516a3
Reported VSO-1665674 "/clr C++20 has incorrect results for various ra…
StephanTLavavej Nov 6, 2022
db8046c
Reported VSO-1666161 "/clr C++20 silent bad codegen for bit_cast<floa…
StephanTLavavej Nov 6, 2022
fb51473
Reported VSO-1666178 "/clr C++20 x64 /O2 backend assertion SY_ISUSERV…
StephanTLavavej Nov 6, 2022
6ca2f0d
Reported VSO-1666180 "/clr C++20 x64 System.AccessViolationException …
StephanTLavavej Nov 6, 2022
998cbb5
Perma-workaround VSO-1663301 "/clr C++20 emits bogus error C2131 'exp…
StephanTLavavej Nov 6, 2022
5470546
Avoid warnings C4561 and C4575 for __fastcall and __vectorcall.
StephanTLavavej Nov 6, 2022
a2ff695
Avoid using <cfenv> macros when they aren't available for /clr.
StephanTLavavej Nov 6, 2022
b672241
Comment why we aren't testing P0088R3_variant with /clr C++20.
StephanTLavavej Nov 6, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions stl/inc/__msvc_all_public_headers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,19 +142,16 @@
#include <__msvc_cxx_stdatomic.hpp>
#include <atomic>
#include <barrier>
#include <latch>
#include <semaphore>
#include <stop_token>
#endif // _M_CEE_PURE

#ifndef _M_CEE
#include <condition_variable>
#include <execution>
#include <future>
#include <latch>
#include <mutex>
#include <semaphore>
#include <shared_mutex>
#include <stop_token>
#include <thread>
#endif // _M_CEE
#endif // _M_CEE_PURE

// Non-Core C Wrapper Headers
#include <ccomplex>
Expand Down
14 changes: 14 additions & 0 deletions stl/inc/algorithm
Original file line number Diff line number Diff line change
Expand Up @@ -932,10 +932,17 @@ namespace ranges {
// We've trimmed matching prefixes and matching suffixes.
// Now we need to compare each range's prefix to the other range's suffix.

#ifdef _M_CEE // TRANSITION, VSO-1663257
const auto _ProjectedPred = [&](auto&& _Left, auto&& _Right) -> bool {
return _STD invoke(_Pred, _STD invoke(_Proj1, _STD forward<decltype(_Left)>(_Left)),
_STD invoke(_Proj2, _STD forward<decltype(_Right)>(_Right)));
};
#else // ^^^ workaround / no workaround vvv
const auto _ProjectedPred = [&]<class _Ty1, class _Ty2>(_Ty1&& _Left, _Ty2&& _Right) -> bool {
return _STD invoke(_Pred, _STD invoke(_Proj1, _STD forward<_Ty1>(_Left)),
_STD invoke(_Proj2, _STD forward<_Ty2>(_Right)));
};
#endif // ^^^ no workaround ^^^

const _TrimResult _Res = _Trim_completely(_First1, _Final1, _First2, _Final2, _ProjectedPred);

Expand Down Expand Up @@ -1021,10 +1028,17 @@ namespace ranges {
// We've trimmed matching prefixes and matching suffixes.
// Now we need to compare each range's prefix to the other range's suffix.

#ifdef _M_CEE // TRANSITION, VSO-1663257
const auto _ProjectedPred = [&](auto&& _Left, auto&& _Right) -> bool {
return _STD invoke(_Pred, _STD invoke(_Proj1, _STD forward<decltype(_Left)>(_Left)),
_STD invoke(_Proj2, _STD forward<decltype(_Right)>(_Right)));
};
#else // ^^^ workaround / no workaround vvv
const auto _ProjectedPred = [&]<class _Ty1, class _Ty2>(_Ty1&& _Left, _Ty2&& _Right) -> bool {
return _STD invoke(_Pred, _STD invoke(_Proj1, _STD forward<_Ty1>(_Left)),
_STD invoke(_Proj2, _STD forward<_Ty2>(_Right)));
};
#endif // ^^^ no workaround ^^^

const _TrimResult _Res = _Trim_completely(_First1, _Final1, _First2, _Final2, _ProjectedPred);

Expand Down
14 changes: 10 additions & 4 deletions stl/inc/chrono
Original file line number Diff line number Diff line change
Expand Up @@ -5358,7 +5358,13 @@ namespace chrono {

const _Allowed_bit _Mod = _Modifier == 'E' ? _E_mod : _O_mod;

if (auto _It = _RANGES find(_Table, _Type, &_Table_entry::_Type); _It != _STD end(_Table)) {
#ifdef _M_CEE // TRANSITION, VSO-1664341
constexpr auto _Get_table_entry_type = [](const _Table_entry& _Entry) { return _Entry._Type; };
#else // ^^^ workaround / no workaround vvv
constexpr auto _Get_table_entry_type = &_Table_entry::_Type;
#endif // ^^^ no workaround ^^^

if (auto _It = _RANGES find(_Table, _Type, _Get_table_entry_type); _It != _STD end(_Table)) {
if (_It->_Allowed & _Mod) {
return;
}
Expand Down Expand Up @@ -5679,10 +5685,10 @@ namespace chrono {
return;
}

constexpr bool _Is_ymd =
_Is_any_of_v<_Ty, year_month_day, year_month_day_last, year_month_weekday, year_month_weekday_last>;

const auto _Validate = [&] {
constexpr bool _Is_ymd =
_Is_any_of_v<_Ty, year_month_day, year_month_day_last, year_month_weekday, year_month_weekday_last>;

switch (_Spec._Type) {
case 'a':
case 'A':
Expand Down
3 changes: 2 additions & 1 deletion stl/inc/cmath
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
#include <cstdlib>
#include <xtr1common>

#if !defined(_M_CEE) && !defined(__clang__) && !defined(__CUDACC__) && !defined(__INTEL_COMPILER)
#if !defined(__clang__) && !defined(__CUDACC__) && !defined(__INTEL_COMPILER) \
&& !defined(_M_CEE) // TRANSITION, VSO-1663104
#define _HAS_CMATH_INTRINSICS 1
#else // ^^^ intrinsics available ^^^ / vvv intrinsics unavailable vvv
#define _HAS_CMATH_INTRINSICS 0
Expand Down
6 changes: 3 additions & 3 deletions stl/inc/condition_variable
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ _STL_DISABLE_CLANG_WARNINGS
#pragma push_macro("new")
#undef new

#ifdef _M_CEE
#error <condition_variable> is not supported when compiling with /clr or /clr:pure.
#endif // _M_CEE
#ifdef _M_CEE_PURE
#error <condition_variable> is not supported when compiling with /clr:pure.
#endif // _M_CEE_PURE

_STD_BEGIN
template <class _Lock>
Expand Down
5 changes: 5 additions & 0 deletions stl/inc/format
Original file line number Diff line number Diff line change
Expand Up @@ -1952,7 +1952,12 @@ public:
_NODISCARD size_t _Estimate_required_capacity() const noexcept {
using _CharT = typename _Context::char_type;
size_t _Result = 0;
#ifdef _M_CEE // TRANSITION, VSO-1663257
const auto _Visitor = [&_Result](const auto _Arg) noexcept {
using _ArgTy = remove_const_t<decltype(_Arg)>;
#else // ^^^ workaround / no workaround vvv
const auto _Visitor = [&_Result]<class _ArgTy>(const _ArgTy _Arg) noexcept {
#endif // ^^^ no workaround ^^^
if constexpr (is_same_v<_ArgTy, basic_string_view<_CharT>>) {
_Result += _Arg.size();
} else if constexpr (is_same_v<_ArgTy, const _CharT*>) {
Expand Down
6 changes: 3 additions & 3 deletions stl/inc/future
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
#include <yvals_core.h>
#if _STL_COMPILER_PREPROCESSOR

#ifdef _M_CEE
#error <future> is not supported when compiling with /clr or /clr:pure.
#endif // _M_CEE
#ifdef _M_CEE_PURE
#error <future> is not supported when compiling with /clr:pure.
#endif // _M_CEE_PURE

#ifdef _RESUMABLE_FUNCTIONS_SUPPORTED
#include <experimental/resumable>
Expand Down
8 changes: 8 additions & 0 deletions stl/inc/iterator
Original file line number Diff line number Diff line change
Expand Up @@ -1355,9 +1355,15 @@ public:
_RANGES iter_swap(_Left._Current, _Right.base());
}

#if _ITERATOR_DEBUG_LEVEL != 0
template <common_with<_Iter> _Other>
friend constexpr void _Same_sequence(
const counted_iterator& _Left, const counted_iterator<_Other>& _Right) noexcept {
#ifdef _M_CEE // TRANSITION, VSO-1665606
(void) _Left;
(void) _Right;
#else // ^^^ workaround / no workaround vvv

// Per N4901 [counted.iterator]/3, two counted_iterators x and y refer to elements of the same sequence iff
// for some integer n, next(x.base(), x.count() + n) and next(y.base(), y.count() + n)
// "refer to the same (possibly past-the-end) element".
Expand All @@ -1377,7 +1383,9 @@ public:
"counted_iterators are from different ranges");
}
}
#endif // ^^^ no workaround ^^^
}
#endif // _ITERATOR_DEBUG_LEVEL != 0

template <common_with<_Iter> _Other>
friend constexpr void _Verify_range(const counted_iterator& _Left, const counted_iterator<_Other>& _Right) {
Expand Down
8 changes: 4 additions & 4 deletions stl/inc/memory_resource
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ _EMIT_STL_WARNING(STL4038, "The contents of <memory_resource> are available only
#include <xpolymorphic_allocator.h>
#include <xutility>

#ifndef _M_CEE
#ifndef _M_CEE_PURE
#include <mutex>
#endif // _M_CEE
#endif // _M_CEE_PURE

#pragma pack(push, _CRT_PACKING)
#pragma warning(push, _STL_WARNING_LEVEL)
Expand Down Expand Up @@ -565,7 +565,7 @@ namespace pmr {
pmr::vector<_Pool> _Pools{}; // pools in order of increasing block size
};

#ifndef _M_CEE
#ifndef _M_CEE_PURE
_EXPORT_STD class synchronized_pool_resource : public unsynchronized_pool_resource {
public:
using unsynchronized_pool_resource::unsynchronized_pool_resource;
Expand All @@ -589,7 +589,7 @@ namespace pmr {
private:
mutable mutex _Mtx;
};
#endif // _M_CEE
#endif // _M_CEE_PURE

_EXPORT_STD class monotonic_buffer_resource : public _Identity_equal_resource {
public:
Expand Down
6 changes: 0 additions & 6 deletions stl/inc/mutex
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ _STL_DISABLE_CLANG_WARNINGS
#undef new

_STD_BEGIN
// mutex and recursive_mutex are not supported under /clr
#ifndef _M_CEE
_EXPORT_STD class condition_variable;
_EXPORT_STD class condition_variable_any;

Expand Down Expand Up @@ -103,7 +101,6 @@ public:
recursive_mutex(const recursive_mutex&) = delete;
recursive_mutex& operator=(const recursive_mutex&) = delete;
};
#endif // _M_CEE

_EXPORT_STD struct adopt_lock_t { // indicates adopt lock
explicit adopt_lock_t() = default;
Expand Down Expand Up @@ -563,8 +560,6 @@ void(call_once)(once_flag& _Once, _Fn&& _Fx, _Args&&... _Ax) noexcept(
#undef _WINDOWS_API
#undef _RENAME_WINDOWS_API

// condition_variable, timed_mutex, and recursive_timed_mutex are not supported under /clr
#ifndef _M_CEE
_EXPORT_STD enum class cv_status { // names for wait returns
no_timeout,
timeout
Expand Down Expand Up @@ -930,7 +925,6 @@ private:
unsigned int _My_locked;
thread::id _My_owner;
};
#endif // _M_CEE
_STD_END
#pragma pop_macro("new")
_STL_RESTORE_CLANG_WARNINGS
Expand Down
7 changes: 1 addition & 6 deletions stl/inc/shared_mutex
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,9 @@
#error <shared_mutex> is not supported when compiling with /clr:pure.
#endif // _M_CEE_PURE

#include <condition_variable>
#include <mutex>
#include <xthreads.h>
#ifndef _M_CEE
#include <condition_variable>
#endif // _M_CEE

#pragma pack(push, _CRT_PACKING)
#pragma warning(push, _STL_WARNING_LEVEL)
Expand Down Expand Up @@ -71,8 +69,6 @@ private:
_Smtx_t _Myhandle;
};

// shared_timed_mutex is not supported under /clr
#ifndef _M_CEE
_EXPORT_STD class shared_timed_mutex { // class for mutual exclusion shared across threads
private:
using _Read_cnt_t = unsigned int;
Expand Down Expand Up @@ -230,7 +226,6 @@ private:
_Read_cnt_t _Readers;
bool _Writing;
};
#endif // _M_CEE

_EXPORT_STD template <class _Mutex>
class shared_lock { // shareable lock
Expand Down
17 changes: 7 additions & 10 deletions stl/inc/xlocinfo
Original file line number Diff line number Diff line change
Expand Up @@ -227,10 +227,9 @@ public:
static _Locinfo& __CLRCALL_PURE_OR_CDECL _Locinfo_Addcats(_Locinfo*, int, const char*);

__CLR_OR_THIS_CALL _Locinfo(const char* _Pch = "C")
#ifndef _M_CEE
#ifndef _M_CEE_PURE
: _Lock(_LOCK_LOCALE)
#endif // _M_CEE

#endif // _M_CEE_PURE
{
if (_Pch) {
_Locinfo_ctor(this, _Pch);
Expand All @@ -241,10 +240,9 @@ public:
}

__CLR_OR_THIS_CALL _Locinfo(int _Cat, const char* _Pch)
#ifndef _M_CEE
#ifndef _M_CEE_PURE
: _Lock(_LOCK_LOCALE)
#endif // _M_CEE

#endif // _M_CEE_PURE
{
if (_Pch) {
_Locinfo_ctor(this, _Cat, _Pch);
Expand Down Expand Up @@ -373,12 +371,11 @@ public:
_Locinfo& operator=(const _Locinfo&) = delete;

private:
#ifdef _M_CEE
#ifdef _M_CEE_PURE
_EmptyLockit _Empty_lock; // to maintain same size

#else // _M_CEE
#else // _M_CEE_PURE
_Lockit _Lock; // thread lock, because global locale is altered
#endif // _M_CEE
#endif // _M_CEE_PURE

_Yarn<char> _Days; // weekday names
_Yarn<char> _Months; // month names
Expand Down
12 changes: 9 additions & 3 deletions stl/inc/xthreads.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,15 @@ _INLINE_VAR constexpr size_t _Cnd_internal_imp_alignment = 4;
#endif // _WIN64
#endif // _CRT_WINDOWS

using _Mtx_t = struct _Mtx_internal_imp_t*;

using _Cnd_t = struct _Cnd_internal_imp_t*;
#ifdef _M_CEE // avoid warning LNK4248: unresolved typeref token for '_Mtx_internal_imp_t'; image may not run
using _Mtx_t = void*;
using _Cnd_t = void*;
#else // ^^^ defined(_M_CEE) / !defined(_M_CEE) vvv
struct _Mtx_internal_imp_t;
struct _Cnd_internal_imp_t;
using _Mtx_t = _Mtx_internal_imp_t*;
using _Cnd_t = _Cnd_internal_imp_t*;
#endif // ^^^ !defined(_M_CEE) ^^^

enum { _Thrd_success, _Thrd_nomem, _Thrd_timedout, _Thrd_busy, _Thrd_error };

Expand Down
25 changes: 13 additions & 12 deletions stl/inc/yvals.h
Original file line number Diff line number Diff line change
Expand Up @@ -385,12 +385,14 @@ extern "C++" class _CRTIMP2_PURE_IMPORT _Lockit { // lock while object in existe
int _Locktype;
};

#ifdef _M_CEE
#ifdef _M_CEE_PURE
class _CRTIMP2_PURE_IMPORT _EmptyLockit { // empty lock class used for bin compat
private:
int _Locktype;
};
#endif // _M_CEE_PURE

#ifdef _M_CEE
#ifndef _PREPARE_CONSTRAINED_REGIONS
#ifdef _M_CEE_PURE
#define _PREPARE_CONSTRAINED_REGIONS 1
Expand Down Expand Up @@ -437,11 +439,6 @@ class _CRTIMP2_PURE_IMPORT _EmptyLockit { // empty lock class used for bin compa

#define _END_LOCINFO() _END_LOCK()

#define _RELIABILITY_CONTRACT \
[System::Runtime::ConstrainedExecution::ReliabilityContract( \
System::Runtime::ConstrainedExecution::Consistency::WillNotCorruptState, \
System::Runtime::ConstrainedExecution::Cer::Success)]

#else // _M_CEE
#define _BEGIN_LOCK(_Kind) \
{ \
Expand All @@ -454,8 +451,6 @@ class _CRTIMP2_PURE_IMPORT _EmptyLockit { // empty lock class used for bin compa
_Locinfo _VarName;

#define _END_LOCINFO() }

#define _RELIABILITY_CONTRACT
#endif // _M_CEE

#ifdef _CRTBLD
Expand All @@ -479,6 +474,16 @@ class _CRTIMP2_PURE_IMPORT _Init_locks { // initialize mutexes
static void __cdecl _Init_locks_ctor(_Init_locks*) noexcept;
static void __cdecl _Init_locks_dtor(_Init_locks*) noexcept;
};

#ifdef _M_CEE
#define _RELIABILITY_CONTRACT \
[System::Runtime::ConstrainedExecution::ReliabilityContract( \
System::Runtime::ConstrainedExecution::Consistency::WillNotCorruptState, \
System::Runtime::ConstrainedExecution::Cer::Success)]
#else // _M_CEE
#define _RELIABILITY_CONTRACT
#endif // _M_CEE

#endif // _CRTBLD

#if _HAS_EXCEPTIONS
Expand Down Expand Up @@ -519,10 +524,6 @@ class _CRTIMP2_PURE_IMPORT _Init_locks { // initialize mutexes
#endif // _HAS_EXCEPTIONS
_STD_END

#ifndef _RELIABILITY_CONTRACT
#define _RELIABILITY_CONTRACT
#endif // _RELIABILITY_CONTRACT

#pragma pop_macro("new")
_STL_RESTORE_CLANG_WARNINGS
#pragma warning(pop)
Expand Down
Loading