summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorzhanyong.wan <zhanyong.wan@861a406c-534a-0410-8894-cb66d6ee9925>2011-04-07 18:36:50 (GMT)
committerzhanyong.wan <zhanyong.wan@861a406c-534a-0410-8894-cb66d6ee9925>2011-04-07 18:36:50 (GMT)
commit741d6c0d475664fc48790917cefed455a4307227 (patch)
tree91de61aa484a7ec79aeae5e4ae78184ec8d920b2
parent661758ec1a26a7a2d745e89450cd4e603549cf8c (diff)
downloadgoogletest-741d6c0d475664fc48790917cefed455a4307227.zip
googletest-741d6c0d475664fc48790917cefed455a4307227.tar.gz
googletest-741d6c0d475664fc48790917cefed455a4307227.tar.bz2
makes gtest compatible with HP UX (by Pasi Valminen); fixes a typo in the name of xlC (by Hady Zalek).
-rw-r--r--cmake/internal_utils.cmake6
-rw-r--r--include/gtest/internal/gtest-port.h15
-rw-r--r--include/gtest/internal/gtest-type-util.h11
-rw-r--r--include/gtest/internal/gtest-type-util.h.pump11
-rw-r--r--src/gtest.cc2
-rw-r--r--test/gtest_unittest.cc4
6 files changed, 36 insertions, 13 deletions
diff --git a/cmake/internal_utils.cmake b/cmake/internal_utils.cmake
index e2e224b..7efc2ac 100644
--- a/cmake/internal_utils.cmake
+++ b/cmake/internal_utils.cmake
@@ -85,6 +85,12 @@ macro(config_compiler_and_linker)
# whether RTTI is enabled. Therefore we define GTEST_HAS_RTTI
# explicitly.
set(cxx_no_rtti_flags "-qnortti -DGTEST_HAS_RTTI=0")
+ elseif (CMAKE_CXX_COMPILER_ID STREQUAL "HP")
+ set(cxx_base_flags "-AA -mt")
+ set(cxx_exception_flags "-DGTEST_HAS_EXCEPTIONS=1")
+ set(cxx_no_exception_flags "+noeh -DGTEST_HAS_EXCEPTIONS=0")
+ # RTTI can not be disabled in HP aCC compiler.
+ set(cxx_no_rtti_flags "")
endif()
if (CMAKE_USE_PTHREADS_INIT) # The pthreads library is available and allowed.
diff --git a/include/gtest/internal/gtest-port.h b/include/gtest/internal/gtest-port.h
index 24f2e6f..53cf824 100644
--- a/include/gtest/internal/gtest-port.h
+++ b/include/gtest/internal/gtest-port.h
@@ -86,6 +86,7 @@
// the given platform; otherwise undefined):
// GTEST_OS_AIX - IBM AIX
// GTEST_OS_CYGWIN - Cygwin
+// GTEST_OS_HPUX - HP-UX
// GTEST_OS_LINUX - Linux
// GTEST_OS_LINUX_ANDROID - Google Android
// GTEST_OS_MAC - Mac OS X
@@ -235,6 +236,8 @@
# define GTEST_OS_SOLARIS 1
#elif defined(_AIX)
# define GTEST_OS_AIX 1
+#elif defined(__hpux)
+# define GTEST_OS_HPUX 1
#elif defined __native_client__
# define GTEST_OS_NACL 1
#endif // __CYGWIN__
@@ -309,6 +312,10 @@
# elif defined(__IBMCPP__) && __EXCEPTIONS
// xlC defines __EXCEPTIONS to 1 iff exceptions are enabled.
# define GTEST_HAS_EXCEPTIONS 1
+# elif defined(__HP_aCC)
+// Exception handling is in effect by default in HP aCC compiler. It has to
+// be turned of by +noeh compiler option if desired.
+# define GTEST_HAS_EXCEPTIONS 1
# else
// For other compilers, we assume exceptions are disabled to be
// conservative.
@@ -408,7 +415,7 @@
//
// To disable threading support in Google Test, add -DGTEST_HAS_PTHREAD=0
// to your compiler flags.
-# define GTEST_HAS_PTHREAD (GTEST_OS_LINUX || GTEST_OS_MAC)
+# define GTEST_HAS_PTHREAD (GTEST_OS_LINUX || GTEST_OS_MAC || GTEST_OS_HPUX)
#endif // GTEST_HAS_PTHREAD
#if GTEST_HAS_PTHREAD
@@ -531,7 +538,7 @@
// pops up a dialog window that cannot be suppressed programmatically.
#if (GTEST_OS_LINUX || GTEST_OS_MAC || GTEST_OS_CYGWIN || GTEST_OS_SOLARIS || \
(GTEST_OS_WINDOWS_DESKTOP && _MSC_VER >= 1400) || \
- GTEST_OS_WINDOWS_MINGW || GTEST_OS_AIX)
+ GTEST_OS_WINDOWS_MINGW || GTEST_OS_AIX || GTEST_OS_HPUX)
# define GTEST_HAS_DEATH_TEST 1
# include <vector> // NOLINT
#endif
@@ -544,9 +551,9 @@
// Determines whether to support type-driven tests.
// Typed tests need <typeinfo> and variadic macros, which GCC, VC++ 8.0,
-// Sun Pro CC, and IBM Visual Age support.
+// Sun Pro CC, IBM Visual Age, and HP aCC support.
#if defined(__GNUC__) || (_MSC_VER >= 1400) || defined(__SUNPRO_CC) || \
- defined(__IBMCPP__)
+ defined(__IBMCPP__) || defined(__HP_aCC)
# define GTEST_HAS_TYPED_TEST 1
# define GTEST_HAS_TYPED_TEST_P 1
#endif
diff --git a/include/gtest/internal/gtest-type-util.h b/include/gtest/internal/gtest-type-util.h
index ec9315d..b7b01b0 100644
--- a/include/gtest/internal/gtest-type-util.h
+++ b/include/gtest/internal/gtest-type-util.h
@@ -51,6 +51,8 @@
// libstdc++ (which is where cxxabi.h comes from).
# ifdef __GLIBCXX__
# include <cxxabi.h>
+# elif defined(__HP_aCC)
+# include <acxx_demangle.h>
# endif // __GLIBCXX__
namespace testing {
@@ -64,17 +66,20 @@ String GetTypeName() {
# if GTEST_HAS_RTTI
const char* const name = typeid(T).name();
-# ifdef __GLIBCXX__
+# if defined(__GLIBCXX__) || defined(__HP_aCC)
int status = 0;
// gcc's implementation of typeid(T).name() mangles the type name,
// so we have to demangle it.
- char* const readable_name = abi::__cxa_demangle(name, 0, 0, &status);
+# ifdef __GLIBCXX__
+ using abi::__cxa_demangle;
+# endif // __GLIBCXX__
+ char* const readable_name = __cxa_demangle(name, 0, 0, &status);
const String name_str(status == 0 ? readable_name : name);
free(readable_name);
return name_str;
# else
return name;
-# endif // __GLIBCXX__
+# endif // __GLIBCXX__ || __HP_aCC
# else
diff --git a/include/gtest/internal/gtest-type-util.h.pump b/include/gtest/internal/gtest-type-util.h.pump
index b69ce6e..27f331d 100644
--- a/include/gtest/internal/gtest-type-util.h.pump
+++ b/include/gtest/internal/gtest-type-util.h.pump
@@ -49,6 +49,8 @@ $var n = 50 $$ Maximum length of type lists we want to support.
// libstdc++ (which is where cxxabi.h comes from).
# ifdef __GLIBCXX__
# include <cxxabi.h>
+# elif defined(__HP_aCC)
+# include <acxx_demangle.h>
# endif // __GLIBCXX__
namespace testing {
@@ -62,17 +64,20 @@ String GetTypeName() {
# if GTEST_HAS_RTTI
const char* const name = typeid(T).name();
-# ifdef __GLIBCXX__
+# if defined(__GLIBCXX__) || defined(__HP_aCC)
int status = 0;
// gcc's implementation of typeid(T).name() mangles the type name,
// so we have to demangle it.
- char* const readable_name = abi::__cxa_demangle(name, 0, 0, &status);
+# ifdef __GLIBCXX__
+ using abi::__cxa_demangle;
+# endif // __GLIBCXX__
+ char* const readable_name = __cxa_demangle(name, 0, 0, &status);
const String name_str(status == 0 ? readable_name : name);
free(readable_name);
return name_str;
# else
return name;
-# endif // __GLIBCXX__
+# endif // __GLIBCXX__ || __HP_aCC
# else
diff --git a/src/gtest.cc b/src/gtest.cc
index fc0f801..904d9d7 100644
--- a/src/gtest.cc
+++ b/src/gtest.cc
@@ -2059,7 +2059,7 @@ class GoogleTestFailureException : public ::std::runtime_error {
#endif // GTEST_HAS_EXCEPTIONS
namespace internal {
-// We put these helper functions in the internal namespace as IBM's xIC_r
+// We put these helper functions in the internal namespace as IBM's xlC
// compiler rejects the code if they were declared static.
// Runs the given method and handles SEH exceptions it throws, when
diff --git a/test/gtest_unittest.cc b/test/gtest_unittest.cc
index 46db38d..6834e8c 100644
--- a/test/gtest_unittest.cc
+++ b/test/gtest_unittest.cc
@@ -3824,8 +3824,8 @@ TEST(AssertionTest, NamedEnum) {
// The version of gcc used in XCode 2.2 has a bug and doesn't allow
// anonymous enums in assertions. Therefore the following test is not
// done on Mac.
-// Sun Studio also rejects this code.
-#if !GTEST_OS_MAC && !defined(__SUNPRO_CC)
+// Sun Studio and HP aCC also reject this code.
+#if !GTEST_OS_MAC && !defined(__SUNPRO_CC) && !defined(__HP_aCC)
// Tests using assertions with anonymous enums.
enum {