From 429432e341b3d68a8a9be079e739a587d41b48b8 Mon Sep 17 00:00:00 2001 From: Robert Shade Date: Wed, 2 Aug 2023 14:09:54 -0400 Subject: [PATCH] Avoid unreachable code warning --- googlemock/include/gmock/gmock-actions.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/googlemock/include/gmock/gmock-actions.h b/googlemock/include/gmock/gmock-actions.h index bd9ba73e..f20258bc 100644 --- a/googlemock/include/gmock/gmock-actions.h +++ b/googlemock/include/gmock/gmock-actions.h @@ -175,9 +175,15 @@ struct BuiltInDefaultValueGetter { static T Get() { Assert(false, __FILE__, __LINE__, "Default action undefined for the function return type."); - return internal::Invalid(); +#if defined(__GNUC__) || defined(__clang__) + __builtin_unreachable(); +#elif defined(_MSC_VER) + __assume(0); +#else + return Invalid(); // The above statement will never be reached, but is required in // order for this function to compile. +#endif } };