Skip to content

Up non-MSVC warning levels #127

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ option(UTPP_USE_PLUS_SIGN
option(UTPP_INCLUDE_TESTS_IN_BUILD
"Set this to OFF if you do not wish to automatically build or run unit tests as part of the default cmake --build"
ON)
option(UTPP_AMPLIFY_WARNINGS
"Set this to OFF if you wish to use CMake default warning levels; should generally only use to work around support issues for your specific compiler"
ON)

if(MSVC14 OR MSVC12)
# has the support we need
Expand All @@ -23,6 +26,17 @@ else()
endif()
endif()

# up warning level for project
if (${UTPP_AMPLIFY_WARNINGS})
# instead of getting compiler specific, we're going to try making an assumption that an existing /W# means
# we are dealing with an MSVC or MSVC-like compiler (e.g. Intel on Windows)
if(CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /WX")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Werror")
endif()
endif()

# get the main sources
file(GLOB headers_ RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} UnitTest++/*.h)
file(GLOB sources_ RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} UnitTest++/*.cpp)
Expand Down
4 changes: 2 additions & 2 deletions UnitTest++/Posix/SignalTranslator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ namespace UnitTest {
sigaction( SIGFPE, &action, &m_old_SIGFPE_action );
sigaction( SIGTRAP, &action, &m_old_SIGTRAP_action );
sigaction( SIGBUS, &action, &m_old_SIGBUS_action );
sigaction( SIGILL, &action, &m_old_SIGBUS_action );
sigaction( SIGILL, &action, &m_old_SIGILL_action );
}

SignalTranslator::~SignalTranslator()
{
sigaction( SIGILL, &m_old_SIGBUS_action, 0 );
sigaction( SIGILL, &m_old_SIGILL_action, 0 );
sigaction( SIGBUS, &m_old_SIGBUS_action, 0 );
sigaction( SIGTRAP, &m_old_SIGTRAP_action, 0 );
sigaction( SIGFPE, &m_old_SIGFPE_action, 0 );
Expand Down
3 changes: 1 addition & 2 deletions UnitTest++/Posix/SignalTranslator.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ namespace UnitTest {
struct sigaction m_old_SIGTRAP_action;
struct sigaction m_old_SIGSEGV_action;
struct sigaction m_old_SIGBUS_action;
struct sigaction m_old_SIGABRT_action;
struct sigaction m_old_SIGALRM_action;
struct sigaction m_old_SIGILL_action;
};

#if !defined (__GNUC__)
Expand Down
3 changes: 3 additions & 0 deletions UnitTest++/RequiredCheckTestReporter.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ namespace UnitTest {
bool Next();

private:
RequiredCheckTestReporter(RequiredCheckTestReporter const&);
RequiredCheckTestReporter& operator =(RequiredCheckTestReporter const&);

TestResults& m_results;
TestReporter* m_originalTestReporter;
ThrowingTestReporter m_throwingReporter;
Expand Down
6 changes: 3 additions & 3 deletions tests/TestMemoryOutStream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ using namespace std;

namespace {

const char* const maxSignedIntegralStr(size_t nBytes)
const char* maxSignedIntegralStr(size_t nBytes)
{
switch(nBytes)
{
Expand All @@ -28,7 +28,7 @@ namespace {
}
}

const char* const minSignedIntegralStr(size_t nBytes)
const char* minSignedIntegralStr(size_t nBytes)
{
switch(nBytes)
{
Expand All @@ -45,7 +45,7 @@ namespace {
}
}

const char* const maxUnsignedIntegralStr(size_t nBytes)
const char* maxUnsignedIntegralStr(size_t nBytes)
{
switch(nBytes)
{
Expand Down