summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkosak <kosak@google.com>2014-11-17 02:11:23 (GMT)
committerkosak <kosak@google.com>2014-11-17 02:11:23 (GMT)
commit074ed8c8ea5732a71748e41e95e2d7e17d782302 (patch)
tree593bd4adefb1a778ce2ddd5e269ebbc2e3a7f206
parent71271d2c95fdf54a3782edea360dca188f926019 (diff)
downloadgoogletest-074ed8c8ea5732a71748e41e95e2d7e17d782302.zip
googletest-074ed8c8ea5732a71748e41e95e2d7e17d782302.tar.gz
googletest-074ed8c8ea5732a71748e41e95e2d7e17d782302.tar.bz2
Clang-on-Windows can support GTEST_ATTRIBUTE_UNUSED_.
-rw-r--r--include/gtest/internal/gtest-port.h17
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.
//