mirror of
https://github.com/jarro2783/cxxopts.git
synced 2026-01-18 01:11:24 +01:00
-Wsuggest-override is not supported by gcc before 5.0 (#283)
* -Wsuggest-override is not supported by gcc before 5.0 * GCC prior to 5.0 should ignore not only -Wnon-virtual-dtor but also -Weffc++, otherwise non-virtual destructor problems will still be reported. * The `#pragma GCC diagnostic push' should be used before setting up the temporary environment.
This commit is contained in:
@@ -74,8 +74,10 @@ function(cxxopts_enable_warnings)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W2")
|
||||
elseif(CMAKE_CXX_COMPILER_ID MATCHES "[Cc]lang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU")
|
||||
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU")
|
||||
if (${CMAKE_CXX_COMPILER_VERSION} VERSION_GREATER_EQUAL 5.0)
|
||||
set(COMPILER_SPECIFIC_FLAGS "-Wsuggest-override")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Werror -Wextra -Wshadow -Weffc++ -Wsign-compare -Wshadow -Wwrite-strings -Wpointer-arith -Winit-self -Wconversion -Wno-sign-conversion ${COMPILER_SPECIFIC_FLAGS}")
|
||||
endif()
|
||||
|
||||
@@ -288,8 +288,9 @@ namespace cxxopts
|
||||
#if defined(__GNUC__)
|
||||
// GNU GCC with -Weffc++ will issue a warning regarding the upcoming class, we want to silence it:
|
||||
// warning: base class 'class std::enable_shared_from_this<cxxopts::Value>' has accessible non-virtual destructor
|
||||
#pragma GCC diagnostic ignored "-Wnon-virtual-dtor"
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wnon-virtual-dtor"
|
||||
#pragma GCC diagnostic ignored "-Weffc++"
|
||||
// This will be ignored under other compilers like LLVM clang.
|
||||
#endif
|
||||
class Value : public std::enable_shared_from_this<Value>
|
||||
|
||||
Reference in New Issue
Block a user