Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
yangql
googletest
Commits
41a8bc67
"git@developer.sourcefind.cn:yangql/googletest.git" did not exist on "21d52d3a1d3a956ac9396dd34e9b2b001be9b9b0"
Commit
41a8bc67
authored
Jan 29, 2014
by
kosak
Browse files
Suppress "Conditional expression is constant" warning on Visual Studio.
parent
35956659
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
39 additions
and
1 deletion
+39
-1
cmake/internal_utils.cmake
cmake/internal_utils.cmake
+10
-1
include/gtest/gtest-printers.h
include/gtest/gtest-printers.h
+2
-0
include/gtest/internal/gtest-port.h
include/gtest/internal/gtest-port.h
+25
-0
test/gtest_premature_exit_test.cc
test/gtest_premature_exit_test.cc
+2
-0
No files found.
cmake/internal_utils.cmake
View file @
41a8bc67
...
@@ -55,7 +55,7 @@ macro(config_compiler_and_linker)
...
@@ -55,7 +55,7 @@ macro(config_compiler_and_linker)
if
(
MSVC
)
if
(
MSVC
)
# Newlines inside flags variables break CMake's NMake generator.
# Newlines inside flags variables break CMake's NMake generator.
# TODO(vladl@google.com): Add -RTCs and -RTCu to debug builds.
# TODO(vladl@google.com): Add -RTCs and -RTCu to debug builds.
set
(
cxx_base_flags
"-GS -W4 -WX
-wd4127
-wd4251 -wd4275 -nologo -J -Zi"
)
set
(
cxx_base_flags
"-GS -W4 -WX -wd4251 -wd4275 -nologo -J -Zi"
)
if
(
MSVC_VERSION LESS 1400
)
# 1400 is Visual Studio 2005
if
(
MSVC_VERSION LESS 1400
)
# 1400 is Visual Studio 2005
# Suppress spurious warnings MSVC 7.1 sometimes issues.
# Suppress spurious warnings MSVC 7.1 sometimes issues.
# Forcing value to bool.
# Forcing value to bool.
...
@@ -66,6 +66,15 @@ macro(config_compiler_and_linker)
...
@@ -66,6 +66,15 @@ macro(config_compiler_and_linker)
# Resolved overload was found by argument-dependent lookup.
# Resolved overload was found by argument-dependent lookup.
set
(
cxx_base_flags
"
${
cxx_base_flags
}
-wd4675"
)
set
(
cxx_base_flags
"
${
cxx_base_flags
}
-wd4675"
)
endif
()
endif
()
if
(
MSVC_VERSION LESS 1500
)
# 1500 is Visual Studio 2008
# Conditional expression is constant.
# When compiling with /W4, we get several instances of C4127
# (Conditional expression is constant). In our code, we disable that
# warning on a case-by-case basis. However, on Visual Studio 2005,
# the warning fires on std::list. Therefore on that compiler and earlier,
# we disable the warning project-wide.
set
(
cxx_base_flags
"
${
cxx_base_flags
}
-wd4127"
)
endif
()
if
(
NOT
(
MSVC_VERSION LESS 1700
))
# 1700 is Visual Studio 2012.
if
(
NOT
(
MSVC_VERSION LESS 1700
))
# 1700 is Visual Studio 2012.
# Suppress "unreachable code" warning on VS 2012 and later.
# Suppress "unreachable code" warning on VS 2012 and later.
# http://stackoverflow.com/questions/3232669 explains the issue.
# http://stackoverflow.com/questions/3232669 explains the issue.
...
...
include/gtest/gtest-printers.h
View file @
41a8bc67
...
@@ -835,7 +835,9 @@ struct TuplePrefixPrinter {
...
@@ -835,7 +835,9 @@ struct TuplePrefixPrinter {
template
<
typename
Tuple
>
template
<
typename
Tuple
>
static
void
PrintPrefixTo
(
const
Tuple
&
t
,
::
std
::
ostream
*
os
)
{
static
void
PrintPrefixTo
(
const
Tuple
&
t
,
::
std
::
ostream
*
os
)
{
TuplePrefixPrinter
<
N
-
1
>::
PrintPrefixTo
(
t
,
os
);
TuplePrefixPrinter
<
N
-
1
>::
PrintPrefixTo
(
t
,
os
);
GTEST_INTENTIONAL_CONST_COND_PUSH_
if
(
N
>
1
)
{
if
(
N
>
1
)
{
GTEST_INTENTIONAL_CONST_COND_POP_
*
os
<<
", "
;
*
os
<<
", "
;
}
}
UniversalPrinter
<
UniversalPrinter
<
...
...
include/gtest/internal/gtest-port.h
View file @
41a8bc67
...
@@ -197,6 +197,10 @@
...
@@ -197,6 +197,10 @@
// GTEST_DISALLOW_ASSIGN_ - disables operator=.
// GTEST_DISALLOW_ASSIGN_ - disables operator=.
// GTEST_DISALLOW_COPY_AND_ASSIGN_ - disables copy ctor and operator=.
// GTEST_DISALLOW_COPY_AND_ASSIGN_ - disables copy ctor and operator=.
// GTEST_MUST_USE_RESULT_ - declares that a function's result must be used.
// GTEST_MUST_USE_RESULT_ - declares that a function's result must be used.
// GTEST_INTENTIONAL_CONST_COND_PUSH_ - start code section where MSVC C4127 is
// suppressed (constant conditional).
// GTEST_INTENTIONAL_CONST_COND_POP_ - finish code section where MSVC C4127
// is suppressed.
//
//
// C++11 feature wrappers:
// C++11 feature wrappers:
//
//
...
@@ -834,6 +838,25 @@ using ::std::tuple_size;
...
@@ -834,6 +838,25 @@ using ::std::tuple_size;
# define GTEST_MOVE_(x) x
# define GTEST_MOVE_(x) x
#endif
#endif
// MS C++ compiler emits warning when a conditional expression is compile time
// constant. In some contexts this warning is false positive and needs to be
// suppressed. Use the following two macros in such cases:
//
// GTEST_INTENTIONAL_CONST_COND_PUSH_
// while (true) {
// GTEST_INTENTIONAL_CONST_COND_POP_
// }
#if defined(_MSC_VER)
# define GTEST_INTENTIONAL_CONST_COND_PUSH_ \
__pragma(warning(push)) \
__pragma(warning(disable: 4127))
# define GTEST_INTENTIONAL_CONST_COND_POP_ \
__pragma(warning(pop))
#else
# define GTEST_INTENTIONAL_CONST_COND_PUSH_
# define GTEST_INTENTIONAL_CONST_COND_POP_
#endif
// Determine whether the compiler supports Microsoft's Structured Exception
// Determine whether the compiler supports Microsoft's Structured Exception
// Handling. This is supported by several Windows compilers but generally
// Handling. This is supported by several Windows compilers but generally
// does not exist on any other system.
// does not exist on any other system.
...
@@ -1248,7 +1271,9 @@ inline To DownCast_(From* f) { // so we only accept pointers
...
@@ -1248,7 +1271,9 @@ inline To DownCast_(From* f) { // so we only accept pointers
// for compile-time type checking, and has no overhead in an
// for compile-time type checking, and has no overhead in an
// optimized build at run-time, as it will be optimized away
// optimized build at run-time, as it will be optimized away
// completely.
// completely.
GTEST_INTENTIONAL_CONST_COND_PUSH_
if
(
false
)
{
if
(
false
)
{
GTEST_INTENTIONAL_CONST_COND_POP_
const
To
to
=
NULL
;
const
To
to
=
NULL
;
::
testing
::
internal
::
ImplicitCast_
<
From
*>
(
to
);
::
testing
::
internal
::
ImplicitCast_
<
From
*>
(
to
);
}
}
...
...
test/gtest_premature_exit_test.cc
View file @
41a8bc67
...
@@ -100,7 +100,9 @@ TEST_F(PrematureExitDeathTest, FileExistsDuringExecutionOfDeathTest) {
...
@@ -100,7 +100,9 @@ TEST_F(PrematureExitDeathTest, FileExistsDuringExecutionOfDeathTest) {
// Tests that TEST_PREMATURE_EXIT_FILE is set where it's expected to
// Tests that TEST_PREMATURE_EXIT_FILE is set where it's expected to
// be set.
// be set.
TEST_F
(
PrematureExitTest
,
TestPrematureExitFileEnvVarIsSet
)
{
TEST_F
(
PrematureExitTest
,
TestPrematureExitFileEnvVarIsSet
)
{
GTEST_INTENTIONAL_CONST_COND_PUSH_
if
(
kTestPrematureExitFileEnvVarShouldBeSet
)
{
if
(
kTestPrematureExitFileEnvVarShouldBeSet
)
{
GTEST_INTENTIONAL_CONST_COND_POP_
const
char
*
const
filepath
=
GetEnv
(
"TEST_PREMATURE_EXIT_FILE"
);
const
char
*
const
filepath
=
GetEnv
(
"TEST_PREMATURE_EXIT_FILE"
);
ASSERT_TRUE
(
filepath
!=
NULL
);
ASSERT_TRUE
(
filepath
!=
NULL
);
ASSERT_NE
(
*
filepath
,
'\0'
);
ASSERT_NE
(
*
filepath
,
'\0'
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment