summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzhanyong.wan <zhanyong.wan@861a406c-534a-0410-8894-cb66d6ee9925>2011-04-15 19:50:39 +0000
committerzhanyong.wan <zhanyong.wan@861a406c-534a-0410-8894-cb66d6ee9925>2011-04-15 19:50:39 +0000
commitf0f9b944496d7786d0b257ed91931ff85223a74d (patch)
tree4bafa72b6022ac8aa3ba7bb3e53d9262ee3d9404
parentaca3d2c1c2cac957f4232c2feaf529387ef7fcb6 (diff)
downloadgoogletest-f0f9b944496d7786d0b257ed91931ff85223a74d.tar.gz
Fixes XL C++ 10.1 compiler errors (based on patch by Hady Zalek); cleans up formatting of GTEST_NO_INLINE_.
git-svn-id: http://googletest.googlecode.com/svn/trunk@572 861a406c-534a-0410-8894-cb66d6ee9925
-rw-r--r--include/gtest/internal/gtest-internal.h26
-rw-r--r--include/gtest/internal/gtest-port.h8
2 files changed, 20 insertions, 14 deletions
diff --git a/include/gtest/internal/gtest-internal.h b/include/gtest/internal/gtest-internal.h
index cd6fd79..7aa1197 100644
--- a/include/gtest/internal/gtest-internal.h
+++ b/include/gtest/internal/gtest-internal.h
@@ -195,22 +195,31 @@ class GTEST_API_ ScopedTrace {
template <typename T>
String StreamableToString(const T& streamable);
+// The Symbian compiler has a bug that prevents it from selecting the
+// correct overload of FormatForComparisonFailureMessage (see below)
+// unless we pass the first argument by reference. If we do that,
+// however, Visual Age C++ 10.1 generates a compiler error. Therefore
+// we only apply the work-around for Symbian.
+#if defined(__SYMBIAN32__)
+# define GTEST_CREF_WORKAROUND_ const&
+#else
+# define GTEST_CREF_WORKAROUND_
+#endif
+
// When this operand is a const char* or char*, if the other operand
// is a ::std::string or ::string, we print this operand as a C string
// rather than a pointer (we do the same for wide strings); otherwise
// we print it as a pointer to be safe.
// This internal macro is used to avoid duplicated code.
-// Making the first operand const reference works around a bug in the
-// Symbian compiler which is unable to select the correct specialization of
-// FormatForComparisonFailureMessage.
#define GTEST_FORMAT_IMPL_(operand2_type, operand1_printer)\
inline String FormatForComparisonFailureMessage(\
- operand2_type::value_type* const& str, const operand2_type& /*operand2*/) {\
+ operand2_type::value_type* GTEST_CREF_WORKAROUND_ str, \
+ const operand2_type& /*operand2*/) {\
return operand1_printer(str);\
}\
inline String FormatForComparisonFailureMessage(\
- const operand2_type::value_type* const& str, \
+ const operand2_type::value_type* GTEST_CREF_WORKAROUND_ str, \
const operand2_type& /*operand2*/) {\
return operand1_printer(str);\
}
@@ -233,13 +242,10 @@ GTEST_FORMAT_IMPL_(::wstring, String::ShowWideCStringQuoted)
// printed is a char/wchar_t pointer and the other operand is not a
// string/wstring object. In such cases, we just print the operand as
// a pointer to be safe.
-//
-// Making the first operand const reference works around a bug in the
-// Symbian compiler which is unable to select the correct specialization of
-// FormatForComparisonFailureMessage.
#define GTEST_FORMAT_CHAR_PTR_IMPL_(CharType) \
template <typename T> \
- String FormatForComparisonFailureMessage(CharType* const& p, const T&) { \
+ String FormatForComparisonFailureMessage(CharType* GTEST_CREF_WORKAROUND_ p, \
+ const T&) { \
return PrintToString(static_cast<const void*>(p)); \
}
diff --git a/include/gtest/internal/gtest-port.h b/include/gtest/internal/gtest-port.h
index c6d102a..157b47f 100644
--- a/include/gtest/internal/gtest-port.h
+++ b/include/gtest/internal/gtest-port.h
@@ -662,12 +662,12 @@
# define GTEST_API_
#endif
-#if defined(__GNUC__)
+#ifdef __GNUC__
// Ask the compiler to never inline a given function.
-#define GTEST_NO_INLINE_ __attribute__((noinline))
+# define GTEST_NO_INLINE_ __attribute__((noinline))
#else
-#define GTEST_NO_INLINE_
-#endif // __GNUC__
+# define GTEST_NO_INLINE_
+#endif
namespace testing {