summaryrefslogtreecommitdiffstats
path: root/googlemock/include/gmock/internal
diff options
context:
space:
mode:
authorAbseil Team <absl-team@google.com>2022-04-13 14:27:23 (GMT)
committerCopybara-Service <copybara-worker@google.com>2022-04-13 14:28:00 (GMT)
commit733f875989a6fba05f4c366ea7b2ba4054994a7e (patch)
treed255f518fa0b7d38c57caa6374e39b60a0682409 /googlemock/include/gmock/internal
parenta1cc8c55195661a58ad60c3bb062a0b9c302710d (diff)
downloadgoogletest-733f875989a6fba05f4c366ea7b2ba4054994a7e.zip
googletest-733f875989a6fba05f4c366ea7b2ba4054994a7e.tar.gz
googletest-733f875989a6fba05f4c366ea7b2ba4054994a7e.tar.bz2
Replace infinite recursion call (intentionally invoking undefined behavior to indicate unreachability) with explicit unreachability marker.
PiperOrigin-RevId: 441474979 Change-Id: I1fcbb437026631212fec954c663482bb7e1cf819
Diffstat (limited to 'googlemock/include/gmock/internal')
-rw-r--r--googlemock/include/gmock/internal/gmock-internal-utils.h9
1 files changed, 6 insertions, 3 deletions
diff --git a/googlemock/include/gmock/internal/gmock-internal-utils.h b/googlemock/include/gmock/internal/gmock-internal-utils.h
index 22fff5c..b1343fd 100644
--- a/googlemock/include/gmock/internal/gmock-internal-utils.h
+++ b/googlemock/include/gmock/internal/gmock-internal-utils.h
@@ -305,10 +305,13 @@ GTEST_API_ WithoutMatchers GetWithoutMatchers();
template <typename T>
inline T Invalid() {
Assert(false, "", -1, "Internal error: attempt to return invalid value");
- // This statement is unreachable, and would never terminate even if it
- // could be reached. It is provided only to placate compiler warnings
- // about missing return statements.
+#if defined(__GNUC__) || defined(__clang__)
+ __builtin_unreachable();
+#elif defined(_MSC_VER)
+ __assume(0);
+#else
return Invalid<T>();
+#endif
}
#ifdef _MSC_VER