diff --git a/stl/inc/yvals.h b/stl/inc/yvals.h index 0cb7946ddff..e060f5ae8e6 100644 --- a/stl/inc/yvals.h +++ b/stl/inc/yvals.h @@ -440,6 +440,10 @@ class _CRTIMP2_PURE_IMPORT _EmptyLockit { // empty lock class used for bin compa #endif // ^^^ !defined(_M_CEE_PURE) ^^^ #endif // !defined(_PREPARE_CONSTRAINED_REGIONS) +// Note: PrepareConstrainedRegions is not supported in .NET versions 6.0 and later. /clr:pure is +// also not supported in /clr:netcore mode (which targets .NET 8.0 and later), so +// _PREPARE_CONSTRAINED_REGIONS == 0 in that case. + #if _PREPARE_CONSTRAINED_REGIONS #define _BEGIN_LOCK(_Kind) \ { \ diff --git a/stl/src/xmtx.hpp b/stl/src/xmtx.hpp index 2d5b7d1df5b..a9848b69065 100644 --- a/stl/src/xmtx.hpp +++ b/stl/src/xmtx.hpp @@ -10,10 +10,20 @@ #include #ifdef _M_CEE +#if _PREPARE_CONSTRAINED_REGIONS +#define _CRT_SUPPRESS_C4950 +#define _CRT_RESTORE_C4950 +#else // ^^^ _PREPARE_CONSTRAINED_REGIONS / !_PREPARE_CONSTRAINED_REGIONS vvv +// Constrained regions are obsolete in .NET 6 and above. +#define _CRT_SUPPRESS_C4950 __pragma(warning(push)) _pragma(warning(disable : 4950)) +#define _CRT_RESTORE_C4950 __pragma(warning(pop)) +#endif // ^^^ !_PREPARE_CONSTRAINED_REGIONS ^^^ #define _RELIABILITY_CONTRACT \ + _CRT_SUPPRESS_C4950 \ [System::Runtime::ConstrainedExecution::ReliabilityContract( \ System::Runtime::ConstrainedExecution::Consistency::WillNotCorruptState, \ - System::Runtime::ConstrainedExecution::Cer::Success)] + System::Runtime::ConstrainedExecution::Cer::Success)] /**/ \ + _CRT_RESTORE_C4950 #else // ^^^ defined(_M_CEE) / !defined(_M_CEE) vvv #define _RELIABILITY_CONTRACT #endif // ^^^ !defined(_M_CEE) ^^^