Fix GCC 12.1.0 -Winfinite-recursion
Fix GCC 12.1.0 -Winfinite-recursion in gmock-internal-utils.h. This
warning has been fixed in GoogleTest v1.12.1.
Change-Id: I989929f3a74503ce32112828808b22d44431b733
diff --git a/third_party/googletest/README.libaom b/third_party/googletest/README.libaom
index a461f36..6ac8543 100644
--- a/third_party/googletest/README.libaom
+++ b/third_party/googletest/README.libaom
@@ -29,3 +29,6 @@
src
LICENSE
README.md
+- Cherry-pick cl/441474979: Replace infinite recursion call
+ (intentionally invoking undefined behavior to indicate unreachability)
+ with explicit unreachability marker.
diff --git a/third_party/googletest/src/googlemock/include/gmock/internal/gmock-internal-utils.h b/third_party/googletest/src/googlemock/include/gmock/internal/gmock-internal-utils.h
index 317544a..4c98efc 100644
--- a/third_party/googletest/src/googlemock/include/gmock/internal/gmock-internal-utils.h
+++ b/third_party/googletest/src/googlemock/include/gmock/internal/gmock-internal-utils.h
@@ -295,10 +295,13 @@
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