diff options
author | kosak@google.com <kosak@google.com@861a406c-534a-0410-8894-cb66d6ee9925> | 2014-11-17 02:11:23 +0000 |
---|---|---|
committer | kosak@google.com <kosak@google.com@861a406c-534a-0410-8894-cb66d6ee9925> | 2014-11-17 02:11:23 +0000 |
commit | 4f2dd9de6f85d34fcfa87e3cce7ed0a73f746b61 (patch) | |
tree | 593bd4adefb1a778ce2ddd5e269ebbc2e3a7f206 | |
parent | cf186cf112e9944c3f9651f39bf473c5f84b0ca3 (diff) | |
download | googletest-4f2dd9de6f85d34fcfa87e3cce7ed0a73f746b61.tar.gz |
Clang-on-Windows can support GTEST_ATTRIBUTE_UNUSED_.
git-svn-id: http://googletest.googlecode.com/svn/trunk@697 861a406c-534a-0410-8894-cb66d6ee9925
-rw-r--r-- | include/gtest/internal/gtest-port.h | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/include/gtest/internal/gtest-port.h b/include/gtest/internal/gtest-port.h index dcb095c..e7ddda5 100644 --- a/include/gtest/internal/gtest-port.h +++ b/include/gtest/internal/gtest-port.h @@ -879,7 +879,12 @@ using ::std::tuple_size; // compiler the variable/parameter does not have to be used. #if defined(__GNUC__) && !defined(COMPILER_ICC) # define GTEST_ATTRIBUTE_UNUSED_ __attribute__ ((unused)) -#else +#elif defined(__clang__) +# if __has_attribute(unused) +# define GTEST_ATTRIBUTE_UNUSED_ __attribute__ ((unused)) +# endif +#endif +#ifndef GTEST_ATTRIBUTE_UNUSED_ # define GTEST_ATTRIBUTE_UNUSED_ #endif @@ -1041,16 +1046,22 @@ class Secret; // the expression is false, most compilers will issue a warning/error // containing the name of the variable. +#if GTEST_LANG_CXX11 +# define GTEST_COMPILE_ASSERT_(expr, msg) static_assert(expr, #msg) +#else // !GTEST_LANG_CXX11 template <bool> -struct CompileAssert { + struct CompileAssert { }; -#define GTEST_COMPILE_ASSERT_(expr, msg) \ +# define GTEST_COMPILE_ASSERT_(expr, msg) \ typedef ::testing::internal::CompileAssert<(static_cast<bool>(expr))> \ msg[static_cast<bool>(expr) ? 1 : -1] GTEST_ATTRIBUTE_UNUSED_ +#endif // !GTEST_LANG_CXX11 // Implementation details of GTEST_COMPILE_ASSERT_: // +// (In C++11, we simply use static_assert instead of the following) +// // - GTEST_COMPILE_ASSERT_ works by defining an array type that has -1 // elements (and thus is invalid) when the expression is false. // |