Fix compilation with -Wundef.
Fixes #3267 PiperOrigin-RevId: 513946600 Change-Id: I0dd1daa04aeb735a238c4c0af6676565d64cbc21
This commit is contained in:
		
				
					committed by
					
						
						Copybara-Service
					
				
			
			
				
	
			
			
			
						parent
						
							2ddba26691
						
					
				
				
					commit
					d92a270d2d
				
			@@ -91,13 +91,13 @@ macro(config_compiler_and_linker)
 | 
			
		||||
      set(cxx_base_flags "${cxx_base_flags} -utf-8")
 | 
			
		||||
    endif()
 | 
			
		||||
  elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
 | 
			
		||||
    set(cxx_base_flags "-Wall -Wshadow -Wconversion")
 | 
			
		||||
    set(cxx_base_flags "-Wall -Wshadow -Wconversion -Wundef")
 | 
			
		||||
    set(cxx_exception_flags "-fexceptions")
 | 
			
		||||
    set(cxx_no_exception_flags "-fno-exceptions")
 | 
			
		||||
    set(cxx_strict_flags "-W -Wpointer-arith -Wreturn-type -Wcast-qual -Wwrite-strings -Wswitch -Wunused-parameter -Wcast-align -Wchar-subscripts -Winline -Wredundant-decls")
 | 
			
		||||
    set(cxx_no_rtti_flags "-fno-rtti")
 | 
			
		||||
  elseif (CMAKE_COMPILER_IS_GNUCXX)
 | 
			
		||||
    set(cxx_base_flags "-Wall -Wshadow")
 | 
			
		||||
    set(cxx_base_flags "-Wall -Wshadow -Wundef")
 | 
			
		||||
    if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 7.0.0)
 | 
			
		||||
      set(cxx_base_flags "${cxx_base_flags} -Wno-error=dangling-else")
 | 
			
		||||
    endif()
 | 
			
		||||
 
 | 
			
		||||
@@ -1747,7 +1747,7 @@ class TestWithParam : public Test, public WithParamInterface<T> {};
 | 
			
		||||
 | 
			
		||||
// Define this macro to 1 to omit the definition of FAIL(), which is a
 | 
			
		||||
// generic name and clashes with some other libraries.
 | 
			
		||||
#if !GTEST_DONT_DEFINE_FAIL
 | 
			
		||||
#if !(defined(GTEST_DONT_DEFINE_FAIL) && GTEST_DONT_DEFINE_FAIL)
 | 
			
		||||
#define FAIL() GTEST_FAIL()
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
@@ -1756,7 +1756,7 @@ class TestWithParam : public Test, public WithParamInterface<T> {};
 | 
			
		||||
 | 
			
		||||
// Define this macro to 1 to omit the definition of SUCCEED(), which
 | 
			
		||||
// is a generic name and clashes with some other libraries.
 | 
			
		||||
#if !GTEST_DONT_DEFINE_SUCCEED
 | 
			
		||||
#if !(defined(GTEST_DONT_DEFINE_SUCCEED) && GTEST_DONT_DEFINE_SUCCEED)
 | 
			
		||||
#define SUCCEED() GTEST_SUCCEED()
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
@@ -1800,19 +1800,19 @@ class TestWithParam : public Test, public WithParamInterface<T> {};
 | 
			
		||||
// Define these macros to 1 to omit the definition of the corresponding
 | 
			
		||||
// EXPECT or ASSERT, which clashes with some users' own code.
 | 
			
		||||
 | 
			
		||||
#if !GTEST_DONT_DEFINE_EXPECT_TRUE
 | 
			
		||||
#if !(defined(GTEST_DONT_DEFINE_EXPECT_TRUE) && GTEST_DONT_DEFINE_EXPECT_TRUE)
 | 
			
		||||
#define EXPECT_TRUE(condition) GTEST_EXPECT_TRUE(condition)
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#if !GTEST_DONT_DEFINE_EXPECT_FALSE
 | 
			
		||||
#if !(defined(GTEST_DONT_DEFINE_EXPECT_FALSE) && GTEST_DONT_DEFINE_EXPECT_FALSE)
 | 
			
		||||
#define EXPECT_FALSE(condition) GTEST_EXPECT_FALSE(condition)
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#if !GTEST_DONT_DEFINE_ASSERT_TRUE
 | 
			
		||||
#if !(defined(GTEST_DONT_DEFINE_ASSERT_TRUE) && GTEST_DONT_DEFINE_ASSERT_TRUE)
 | 
			
		||||
#define ASSERT_TRUE(condition) GTEST_ASSERT_TRUE(condition)
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#if !GTEST_DONT_DEFINE_ASSERT_FALSE
 | 
			
		||||
#if !(defined(GTEST_DONT_DEFINE_ASSERT_FALSE) && GTEST_DONT_DEFINE_ASSERT_FALSE)
 | 
			
		||||
#define ASSERT_FALSE(condition) GTEST_ASSERT_FALSE(condition)
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
@@ -1891,27 +1891,27 @@ class TestWithParam : public Test, public WithParamInterface<T> {};
 | 
			
		||||
// Define macro GTEST_DONT_DEFINE_ASSERT_XY to 1 to omit the definition of
 | 
			
		||||
// ASSERT_XY(), which clashes with some users' own code.
 | 
			
		||||
 | 
			
		||||
#if !GTEST_DONT_DEFINE_ASSERT_EQ
 | 
			
		||||
#if !(defined(GTEST_DONT_DEFINE_ASSERT_EQ) && GTEST_DONT_DEFINE_ASSERT_EQ)
 | 
			
		||||
#define ASSERT_EQ(val1, val2) GTEST_ASSERT_EQ(val1, val2)
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#if !GTEST_DONT_DEFINE_ASSERT_NE
 | 
			
		||||
#if !(defined(GTEST_DONT_DEFINE_ASSERT_NE) && GTEST_DONT_DEFINE_ASSERT_NE)
 | 
			
		||||
#define ASSERT_NE(val1, val2) GTEST_ASSERT_NE(val1, val2)
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#if !GTEST_DONT_DEFINE_ASSERT_LE
 | 
			
		||||
#if !(defined(GTEST_DONT_DEFINE_ASSERT_LE) && GTEST_DONT_DEFINE_ASSERT_LE)
 | 
			
		||||
#define ASSERT_LE(val1, val2) GTEST_ASSERT_LE(val1, val2)
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#if !GTEST_DONT_DEFINE_ASSERT_LT
 | 
			
		||||
#if !(defined(GTEST_DONT_DEFINE_ASSERT_LT) && GTEST_DONT_DEFINE_ASSERT_LT)
 | 
			
		||||
#define ASSERT_LT(val1, val2) GTEST_ASSERT_LT(val1, val2)
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#if !GTEST_DONT_DEFINE_ASSERT_GE
 | 
			
		||||
#if !(defined(GTEST_DONT_DEFINE_ASSERT_GE) && GTEST_DONT_DEFINE_ASSERT_GE)
 | 
			
		||||
#define ASSERT_GE(val1, val2) GTEST_ASSERT_GE(val1, val2)
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#if !GTEST_DONT_DEFINE_ASSERT_GT
 | 
			
		||||
#if !(defined(GTEST_DONT_DEFINE_ASSERT_GT) && GTEST_DONT_DEFINE_ASSERT_GT)
 | 
			
		||||
#define ASSERT_GT(val1, val2) GTEST_ASSERT_GT(val1, val2)
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
@@ -2169,7 +2169,7 @@ constexpr bool StaticAssertTypeEq() noexcept {
 | 
			
		||||
 | 
			
		||||
// Define this macro to 1 to omit the definition of TEST(), which
 | 
			
		||||
// is a generic name and clashes with some other libraries.
 | 
			
		||||
#if !GTEST_DONT_DEFINE_TEST
 | 
			
		||||
#if !(defined(GTEST_DONT_DEFINE_TEST) && GTEST_DONT_DEFINE_TEST)
 | 
			
		||||
#define TEST(test_suite_name, test_name) GTEST_TEST(test_suite_name, test_name)
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
@@ -2201,7 +2201,7 @@ constexpr bool StaticAssertTypeEq() noexcept {
 | 
			
		||||
#define GTEST_TEST_F(test_fixture, test_name)        \
 | 
			
		||||
  GTEST_TEST_(test_fixture, test_name, test_fixture, \
 | 
			
		||||
              ::testing::internal::GetTypeId<test_fixture>())
 | 
			
		||||
#if !GTEST_DONT_DEFINE_TEST_F
 | 
			
		||||
#if !(defined(GTEST_DONT_DEFINE_TEST_F) && GTEST_DONT_DEFINE_TEST_F)
 | 
			
		||||
#define TEST_F(test_fixture, test_name) GTEST_TEST_F(test_fixture, test_name)
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -469,8 +469,12 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION;
 | 
			
		||||
// cleanups prior to that. To reliably check for C++ exception availability with
 | 
			
		||||
// clang, check for
 | 
			
		||||
// __EXCEPTIONS && __has_feature(cxx_exceptions).
 | 
			
		||||
#define GTEST_HAS_EXCEPTIONS (__EXCEPTIONS && __has_feature(cxx_exceptions))
 | 
			
		||||
#elif defined(__GNUC__) && __EXCEPTIONS
 | 
			
		||||
#if defined(__EXCEPTIONS) && __EXCEPTIONS && __has_feature(cxx_exceptions)
 | 
			
		||||
#define GTEST_HAS_EXCEPTIONS 1
 | 
			
		||||
#else
 | 
			
		||||
#define GTEST_HAS_EXCEPTIONS 0
 | 
			
		||||
#endif
 | 
			
		||||
#elif defined(__GNUC__) && defined(__EXCEPTIONS) && __EXCEPTIONS
 | 
			
		||||
// gcc defines __EXCEPTIONS to 1 if and only if exceptions are enabled.
 | 
			
		||||
#define GTEST_HAS_EXCEPTIONS 1
 | 
			
		||||
#elif defined(__SUNPRO_CC)
 | 
			
		||||
@@ -478,7 +482,7 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION;
 | 
			
		||||
// detecting whether they are enabled or not.  Therefore, we assume that
 | 
			
		||||
// they are enabled unless the user tells us otherwise.
 | 
			
		||||
#define GTEST_HAS_EXCEPTIONS 1
 | 
			
		||||
#elif defined(__IBMCPP__) && __EXCEPTIONS
 | 
			
		||||
#elif defined(__IBMCPP__) && defined(__EXCEPTIONS) && __EXCEPTIONS
 | 
			
		||||
// xlC defines __EXCEPTIONS to 1 if and only if exceptions are enabled.
 | 
			
		||||
#define GTEST_HAS_EXCEPTIONS 1
 | 
			
		||||
#elif defined(__HP_aCC)
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user