From: Bruce Forstall Date: Tue, 23 Aug 2016 00:34:44 +0000 (-0700) Subject: Conditionally disable C4702 "unreachable code" warnings X-Git-Tag: submit/tizen/20210909.063632~11030^2~9604^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1daba4acb6370ca3c3a87ee61c0e61a527a89275;p=platform%2Fupstream%2Fdotnet%2Fruntime.git Conditionally disable C4702 "unreachable code" warnings The CLR header file check.h, macro CHECK_MSG_EX, can create unreachable code if the LEAVE_DEBUG_ONLY_CODE macro is not empty (such as it is defined in contract.h) and the _RESULT macro expands to "return". Checked-in compilers used by the TFS-based desktop build (e.g., version 18.10.40116.8) started reporting unreachable code warnings when debugholder.h was changed to no longer #define "return" to something relatively complex. However, newer compilers, such as Visual Studio 2015, used to build the CLR from the open source GitHub repo, still do not report this warning. We don't want to disable this warning for the open source build, which will use a newer compiler. Hence, only disable it for older compilers. Commit migrated from https://github.com/dotnet/coreclr/commit/c3fa47e14b09cd461f723bdc6306e74f98eede4f --- diff --git a/src/coreclr/src/inc/warningcontrol.h b/src/coreclr/src/inc/warningcontrol.h index ce2b76c..c0e21b9 100644 --- a/src/coreclr/src/inc/warningcontrol.h +++ b/src/coreclr/src/inc/warningcontrol.h @@ -71,4 +71,16 @@ #pragma warning(disable :4706) // assignment within conditional expression #pragma warning(error :4806) // unsafe operation involving type 'bool' #pragma warning(disable :4995) // '_OLD_IOSTREAMS_ARE_DEPRECATED': name was marked as #pragma deprecated + +#if defined(_DEBUG) && (!defined(_MSC_FULL_VER) || (_MSC_FULL_VER <= 181040116)) +// The CLR header file check.h, macro CHECK_MSG_EX, can create unreachable code if the LEAVE_DEBUG_ONLY_CODE +// macro is not empty (such as it is defined in contract.h) and the _RESULT macro expands to "return". +// Checked-in compilers used by the TFS-based desktop build (e.g., version 18.10.40116.8) started reporting +// unreachable code warnings when debugholder.h was changed to no longer #define "return" to something relatively +// complex. However, newer compilers, such as Visual Studio 2015, used to build the CLR from the open source +// GitHub repo, still do not report this warning. We don't want to disable this warning for open source build, +// which will use a newer compiler. Hence, only disable it for older compilers. +#pragma warning(disable :4702) // unreachable code +#endif + #endif // defined(_MSC_VER)