From: Ilia Date: Mon, 4 Nov 2019 10:42:54 +0000 (+0300) Subject: Fix invalid-noreturn warning for __CorHlprThrowOOM in corhlpr.h (dotnet/coreclr#23524) X-Git-Tag: submit/tizen/20210909.063632~11030^2~131 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=62d39f480ed12bc2b8beda1acb19e1dac1d39ff0;p=platform%2Fupstream%2Fdotnet%2Fruntime.git Fix invalid-noreturn warning for __CorHlprThrowOOM in corhlpr.h (dotnet/coreclr#23524) * Fix invalid-noreturn warning for __CorHlprThrowOOM in corhlpr.h Commit migrated from https://github.com/dotnet/coreclr/commit/c30381fbe8779e13bbc08591b86cb3d158953212 --- diff --git a/src/coreclr/src/inc/check.h b/src/coreclr/src/inc/check.h index c303cdb..ca335bd 100644 --- a/src/coreclr/src/inc/check.h +++ b/src/coreclr/src/inc/check.h @@ -15,6 +15,7 @@ #include "static_assert.h" #include "daccess.h" +#include "unreachable.h" #ifdef _DEBUG @@ -557,19 +558,6 @@ CHECK CheckValue(TYPENAME &val) #endif // __llvm__ else -#if defined(_MSC_VER) || defined(_PREFIX_) -#if defined(_TARGET_AMD64_) -// Empty methods that consist of UNREACHABLE() result in a zero-sized declspec(noreturn) method -// which causes the pdb file to make the next method declspec(noreturn) as well, thus breaking BBT -// Remove when we get a VC compiler that fixes VSW 449170 -# define __UNREACHABLE() DebugBreak(); __assume(0); -#else -# define __UNREACHABLE() __assume(0) -#endif -#else -#define __UNREACHABLE() __builtin_unreachable() -#endif - #ifdef _DEBUG_IMPL // Note that the "do { } while (0)" syntax trick here doesn't work, as the compiler diff --git a/src/coreclr/src/inc/corhlpr.h b/src/coreclr/src/inc/corhlpr.h index 369fdcc..06f973d 100644 --- a/src/coreclr/src/inc/corhlpr.h +++ b/src/coreclr/src/inc/corhlpr.h @@ -21,6 +21,7 @@ #include "cor.h" #include "corhdr.h" #include "corerror.h" +#include "unreachable.h" // This header is consumed both within the runtime and externally. In the former // case we need to wrap memory allocations, in the latter there is no @@ -43,6 +44,7 @@ inline void DECLSPEC_NORETURN THROW_OUT_OF_MEMORY() static inline void DECLSPEC_NORETURN __CorHlprThrowOOM() { RaiseException(STATUS_NO_MEMORY, 0, 0, NULL); + __UNREACHABLE(); } static inline BYTE *__CorHlprNewThrows(size_t bytes) { diff --git a/src/coreclr/src/inc/gcinfodecoder.h b/src/coreclr/src/inc/gcinfodecoder.h index de14eb0..fee5942 100644 --- a/src/coreclr/src/inc/gcinfodecoder.h +++ b/src/coreclr/src/inc/gcinfodecoder.h @@ -138,12 +138,6 @@ inline BOOL IS_ALIGNED( void* val, size_t alignment ) #endif -// Stuff from check.h: - -#ifndef UNREACHABLE -#define UNREACHABLE() __assume(0) -#endif - // Stuff from eetwain.h: #ifndef _EETWAIN_H diff --git a/src/coreclr/src/inc/unreachable.h b/src/coreclr/src/inc/unreachable.h new file mode 100644 index 0000000..5810f67 --- /dev/null +++ b/src/coreclr/src/inc/unreachable.h @@ -0,0 +1,26 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. +// --------------------------------------------------------------------------- +// unreachable.h +// --------------------------------------------------------------------------- + + +#ifndef __UNREACHABLE_H__ +#define __UNREACHABLE_H__ + +#if defined(_MSC_VER) || defined(_PREFIX_) +#if defined(_TARGET_AMD64_) +// Empty methods that consist of UNREACHABLE() result in a zero-sized declspec(noreturn) method +// which causes the pdb file to make the next method declspec(noreturn) as well, thus breaking BBT +// Remove when we get a VC compiler that fixes VSW 449170 +# define __UNREACHABLE() do { DebugBreak(); __assume(0); } while (0) +#else +# define __UNREACHABLE() __assume(0) +#endif +#else +#define __UNREACHABLE() __builtin_unreachable() +#endif + +#endif // __UNREACHABLE_H__ +