Skip to content

Commit 5294bf9

Browse files
committed
Fix building error for error: fallthrough annotation in unreachable 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.
1 parent bc2bd2b commit 5294bf9

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

src/coreclr/interop/comwrappers.cpp

+10-1
Original file line numberDiff line numberDiff line change
@@ -736,7 +736,16 @@ HRESULT ManagedObjectWrapper::QueryInterface(
736736
return E_NOINTERFACE;
737737

738738
default:
739-
_ASSERTE(false && "Unknown result value");
739+
// NOTE: here the `result == *` of assert is just for avoiding the compiling error
740+
// `fallthrough annotation in unreachable code` within debug mode using clang <=13.
741+
// Because clang versions before 14 had a bug here.
742+
_ASSERTE(
743+
#if defined(__clang__) && (__clang_major__ < 14)
744+
(result == TryInvokeICustomQueryInterfaceResult::FailedToInvoke)
745+
#else
746+
false
747+
#endif
748+
&& "Unknown result value");
740749
FALLTHROUGH;
741750
case TryInvokeICustomQueryInterfaceResult::FailedToInvoke:
742751
// Set the 'lacks' flag since our attempt to use ICustomQueryInterface

src/coreclr/pal/inc/pal.h

-8
Original file line numberDiff line numberDiff line change
@@ -184,14 +184,6 @@ extern bool g_arm64_atomics_present;
184184
#define __has_cpp_attribute(x) (0)
185185
#endif
186186

187-
#ifndef FALLTHROUGH
188-
#if __has_cpp_attribute(fallthrough)
189-
#define FALLTHROUGH [[fallthrough]]
190-
#else // __has_cpp_attribute(fallthrough)
191-
#define FALLTHROUGH
192-
#endif // __has_cpp_attribute(fallthrough)
193-
#endif // FALLTHROUGH
194-
195187
/******************* PAL-Specific Entrypoints *****************************/
196188

197189
#define IsDebuggerPresent PAL_IsDebuggerPresent

0 commit comments

Comments
 (0)