Skip to content

Commit

Permalink
Fix building error for `error: fallthrough annotation in unreachable …
Browse files Browse the repository at this point in the history
…code`

when building on debug mode on loongarch64/arm64/amd64-linux by clang<14.

Also delete `#ifndef FALLTHROUGH` block as dotnet#98336 added after dotnet#98712.
  • Loading branch information
shushanhf committed Apr 8, 2024
1 parent bc2bd2b commit 5294bf9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
11 changes: 10 additions & 1 deletion src/coreclr/interop/comwrappers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -736,7 +736,16 @@ HRESULT ManagedObjectWrapper::QueryInterface(
return E_NOINTERFACE;

default:
_ASSERTE(false && "Unknown result value");
// NOTE: here the `result == *` of assert is just for avoiding the compiling error
// `fallthrough annotation in unreachable code` within debug mode using clang <=13.
// Because clang versions before 14 had a bug here.
_ASSERTE(
#if defined(__clang__) && (__clang_major__ < 14)
(result == TryInvokeICustomQueryInterfaceResult::FailedToInvoke)
#else
false
#endif
&& "Unknown result value");
FALLTHROUGH;
case TryInvokeICustomQueryInterfaceResult::FailedToInvoke:
// Set the 'lacks' flag since our attempt to use ICustomQueryInterface
Expand Down
8 changes: 0 additions & 8 deletions src/coreclr/pal/inc/pal.h
Original file line number Diff line number Diff line change
Expand Up @@ -184,14 +184,6 @@ extern bool g_arm64_atomics_present;
#define __has_cpp_attribute(x) (0)
#endif

#ifndef FALLTHROUGH
#if __has_cpp_attribute(fallthrough)
#define FALLTHROUGH [[fallthrough]]
#else // __has_cpp_attribute(fallthrough)
#define FALLTHROUGH
#endif // __has_cpp_attribute(fallthrough)
#endif // FALLTHROUGH

/******************* PAL-Specific Entrypoints *****************************/

#define IsDebuggerPresent PAL_IsDebuggerPresent
Expand Down

0 comments on commit 5294bf9

Please sign in to comment.