makes gtest compatible with HP UX (by Pasi Valminen); fixes a typo in the name of xlC (by Hady Zalek).

This commit is contained in:
zhanyong.wan 2011-04-07 18:36:50 +00:00
parent 661758ec1a
commit 741d6c0d47
6 changed files with 36 additions and 13 deletions

View File

@ -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.

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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 {