Compare commits

...

5 Commits

Author SHA1 Message Date
Igor Molchanov
7927fc3608
Merge 2aa1e7cc67feb634cc25d6d32e2cb32f0988a886 into 085af2cc08600bdb13827ca40261abcbe5048bb5 2025-11-11 02:40:29 +03:00
makise-homura
2aa1e7cc67 Correctly deal with abi::__cxa_demangle() on LCC
abi::__cxa_demangle("7MyArrayIbLi42EE", nullptr, nullptr, nullptr)
returns "MyArray<bool, 42>" on GCC/x86_64, but "MyArray<bool, (int)42>"
on LCC/e2k. This behavior causes googletest-list-tests-unittest test to
fail.

This commit fixes that by slightly modifying the regex to match this
behavior of abi::__cxa_demangle().
2024-08-30 21:34:07 +03:00
makise-homura
24699b4926 Extend NVC workaround for no-optimize-sibling-calls
__attribute__((optimize("no-optimize-sibling-calls"))) is not supported
for at least some versions of NVC (nVidia HPC compiler), and this case
has a workaround in gtest-port.h. Actually, this is true not just for
NVC (that defines __NVCOMPILER), but for other EDG-based compilers as
well, for example, LCC.

So the correct check here would be not just for __NVCOMPILER, but
for __EDG__ (NVC defines this too, because it is based on EDG).

This commit does this.
2024-08-30 21:34:07 +03:00
makise-homura
df6fa41e1b Eliminate -Wreturn-type (at least on LCC)
There are four GetName<T>() functions that are expected to have
a limited set of possible <T> types. But compiler does not know about
that, and may complain (and in LCC case, does) about no return
operator in the end of these functions.

This commit adds dummy return to each of these functions to eliminate
this warning.
2024-08-30 21:34:07 +03:00
makise-homura
5b2ecaa64e Treat LCC as compiler different from GCC
LCC (eLbrus C/C++ compiler) is an EDG-based compiler that in most cases
is similar in behavior to GNU, but it has different warning options
supported and enabled by default. It seems to have sense to treat LCC
and GNU differently, as CMake supports it from 3.23.

For it to be done, CMake policy CMP0129 should be set to NEW,
and then CMAKE_${LANG}_COMPILER_ID may be checked to be STREQUAL "LCC".

This commit does this, and introduces warning arguments in call
to compiler that are slightly different from GNU to let googletest be
buildable without unexpected warnings.
2024-08-30 21:34:07 +03:00
8 changed files with 20 additions and 6 deletions

View File

@ -3,6 +3,7 @@
cmake_minimum_required(VERSION 3.16)
cmake_policy(SET CMP0129 NEW)
project(googletest-distribution)
set(GOOGLETEST_VERSION 1.16.0)

View File

@ -37,6 +37,7 @@ endif()
# ${gmock_BINARY_DIR}.
# Language "C" is required for find_package(Threads).
cmake_minimum_required(VERSION 3.13)
cmake_policy(SET CMP0129 NEW)
project(gmock VERSION ${GOOGLETEST_VERSION} LANGUAGES CXX C)
if (COMMAND set_up_hermetic_build)

View File

@ -47,6 +47,7 @@ endif()
# Project version.
cmake_minimum_required(VERSION 3.13)
cmake_policy(SET CMP0129 NEW)
project(gtest VERSION ${GOOGLETEST_VERSION} LANGUAGES CXX C)
if (COMMAND set_up_hermetic_build)

View File

@ -102,9 +102,11 @@ macro(config_compiler_and_linker)
if (CMAKE_CXX_COMPILER_ID STREQUAL "IntelLLVM")
set(cxx_base_flags "${cxx_base_flags} -Wno-implicit-float-size-conversion -ffp-model=precise")
endif()
elseif (CMAKE_COMPILER_IS_GNUCXX)
set(cxx_base_flags "-Wall -Wshadow -Wundef")
if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 7.0.0)
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR
CMAKE_CXX_COMPILER_ID STREQUAL "LCC")
set(cxx_base_flags "-Wall -Wundef")
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND
NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 7.0.0)
set(cxx_base_flags "${cxx_base_flags} -Wno-error=dangling-else")
endif()
set(cxx_exception_flags "-fexceptions")
@ -115,6 +117,11 @@ macro(config_compiler_and_linker)
set(cxx_no_rtti_flags "-fno-rtti -DGTEST_HAS_RTTI=0")
set(cxx_strict_flags
"-Wextra -Wno-unused-parameter -Wno-missing-field-initializers")
if (CMAKE_CXX_COMPILER_ID STREQUAL "LCC")
set(cxx_base_flags "${cxx_base_flags} -Wno-unused-variable -Wno-unused-but-set-variable -Wno-unused-function")
else()
set(cxx_base_flags "${cxx_base_flags} -Wshadow")
endif()
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "SunPro")
set(cxx_exception_flags "-features=except")
# Sun Pro doesn't provide macros to indicate whether exceptions and

View File

@ -852,7 +852,7 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION;
// Ask the compiler not to perform tail call optimization inside
// the marked function.
#define GTEST_NO_TAIL_CALL_ __attribute__((disable_tail_calls))
#elif defined(__GNUC__) && !defined(__NVCOMPILER)
#elif defined(__GNUC__) && !defined(__EDG__)
#define GTEST_NO_TAIL_CALL_ \
__attribute__((optimize("no-optimize-sibling-calls")))
#else

View File

@ -74,7 +74,7 @@ TypedTest/0\. # TypeParam = (VeryLo{245}|class VeryLo{239})\.\.\.
TypedTest/1\. # TypeParam = int\s*\*( __ptr64)?
TestA
TestB
TypedTest/2\. # TypeParam = .*MyArray<bool,\s*42>
TypedTest/2\. # TypeParam = .*MyArray<bool,\s*(\(int\))?42>
TestA
TestB
My/TypeParamTest/0\. # TypeParam = (VeryLo{245}|class VeryLo{239})\.\.\.
@ -83,7 +83,7 @@ My/TypeParamTest/0\. # TypeParam = (VeryLo{245}|class VeryLo{239})\.\.\.
My/TypeParamTest/1\. # TypeParam = int\s*\*( __ptr64)?
TestA
TestB
My/TypeParamTest/2\. # TypeParam = .*MyArray<bool,\s*42>
My/TypeParamTest/2\. # TypeParam = .*MyArray<bool,\s*(\(int\))?42>
TestA
TestB
MyInstantiation/ValueParamTest\.

View File

@ -720,6 +720,7 @@ class TypedTestNames {
return std::string("char") + ::testing::PrintToString(i);
if (std::is_same<T, int>::value)
return std::string("int") + ::testing::PrintToString(i);
return std::string("unknown");
}
};
@ -755,6 +756,7 @@ class TypedTestPNames {
if (std::is_same<T, unsigned int>::value) {
return std::string("unsignedInt") + ::testing::PrintToString(i);
}
return std::string("unknown");
}
};

View File

@ -172,6 +172,7 @@ class TypedTestNames {
if (std::is_same<T, int>::value) {
return std::string("int") + ::testing::PrintToString(i);
}
return std::string("unknown");
}
};
@ -320,6 +321,7 @@ class TypeParametrizedTestNames {
if (std::is_same<T, int>::value) {
return std::string("parInt") + ::testing::PrintToString(i);
}
return std::string("unknown");
}
};