diff --git a/cmake/internal_utils.cmake b/cmake/internal_utils.cmake index 68b79780..0954e2de 100644 --- a/cmake/internal_utils.cmake +++ b/cmake/internal_utils.cmake @@ -54,7 +54,7 @@ elseif (CMAKE_COMPILER_IS_GNUCXX) # whether RTTI is enabled. Therefore we define GTEST_HAS_RTTI # explicitly. set(cxx_no_rtti_flags "-fno-rtti -DGTEST_HAS_RTTI=0") - set(cxx_strict_flags "-Wextra") + set(cxx_strict_flags "-Wextra -Wswitch-default") elseif (CMAKE_CXX_COMPILER_ID STREQUAL "SunPro") set(cxx_exception_flags "-features=except") # Sun Pro doesn't provide macros to indicate whether exceptions and diff --git a/include/gtest/internal/gtest-death-test-internal.h b/include/gtest/internal/gtest-death-test-internal.h index e4330848..9bd2aa35 100644 --- a/include/gtest/internal/gtest-death-test-internal.h +++ b/include/gtest/internal/gtest-death-test-internal.h @@ -176,6 +176,8 @@ GTEST_API_ bool ExitedUnsuccessfully(int exit_status); gtest_dt->Abort(::testing::internal::DeathTest::TEST_DID_NOT_DIE); \ break; \ } \ + default: \ + break; \ } \ } \ } else \ diff --git a/include/gtest/internal/gtest-port.h b/include/gtest/internal/gtest-port.h index 0ad570af..aa3d0afd 100644 --- a/include/gtest/internal/gtest-port.h +++ b/include/gtest/internal/gtest-port.h @@ -535,7 +535,7 @@ #ifdef __INTEL_COMPILER #define GTEST_AMBIGUOUS_ELSE_BLOCKER_ #else -#define GTEST_AMBIGUOUS_ELSE_BLOCKER_ switch (0) case 0: // NOLINT +#define GTEST_AMBIGUOUS_ELSE_BLOCKER_ switch (0) case 0: default: // NOLINT #endif // Use this annotation at the end of a struct/class definition to diff --git a/src/gtest.cc b/src/gtest.cc index 9855f53d..a64327b9 100644 --- a/src/gtest.cc +++ b/src/gtest.cc @@ -2504,9 +2504,9 @@ static const char * TestPartResultTypeToString(TestPartResult::Type type) { #else return "Failure\n"; #endif + default: + return "Unknown result type"; } - - return "Unknown result type"; } // Prints a TestPartResult to a String.