Commit 174510285a451d5e2ab2c4054bc88ce8b4ba933d
Committed by
GitHub
1 parent
dd45a080
-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.
Showing
2 changed files
with
5 additions
and
2 deletions
cmake/cxxopts.cmake
| @@ -74,8 +74,10 @@ function(cxxopts_enable_warnings) | @@ -74,8 +74,10 @@ function(cxxopts_enable_warnings) | ||
| 74 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W2") | 74 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W2") |
| 75 | elseif(CMAKE_CXX_COMPILER_ID MATCHES "[Cc]lang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU") | 75 | elseif(CMAKE_CXX_COMPILER_ID MATCHES "[Cc]lang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU") |
| 76 | if (CMAKE_CXX_COMPILER_ID MATCHES "GNU") | 76 | if (CMAKE_CXX_COMPILER_ID MATCHES "GNU") |
| 77 | + if (${CMAKE_CXX_COMPILER_VERSION} VERSION_GREATER_EQUAL 5.0) | ||
| 77 | set(COMPILER_SPECIFIC_FLAGS "-Wsuggest-override") | 78 | set(COMPILER_SPECIFIC_FLAGS "-Wsuggest-override") |
| 78 | - endif() | 79 | + endif() |
| 80 | + endif() | ||
| 79 | 81 | ||
| 80 | 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}") | 82 | 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}") |
| 81 | endif() | 83 | endif() |
include/cxxopts.hpp
| @@ -288,8 +288,9 @@ namespace cxxopts | @@ -288,8 +288,9 @@ namespace cxxopts | ||
| 288 | #if defined(__GNUC__) | 288 | #if defined(__GNUC__) |
| 289 | // GNU GCC with -Weffc++ will issue a warning regarding the upcoming class, we want to silence it: | 289 | // GNU GCC with -Weffc++ will issue a warning regarding the upcoming class, we want to silence it: |
| 290 | // warning: base class 'class std::enable_shared_from_this<cxxopts::Value>' has accessible non-virtual destructor | 290 | // warning: base class 'class std::enable_shared_from_this<cxxopts::Value>' has accessible non-virtual destructor |
| 291 | -#pragma GCC diagnostic ignored "-Wnon-virtual-dtor" | ||
| 292 | #pragma GCC diagnostic push | 291 | #pragma GCC diagnostic push |
| 292 | +#pragma GCC diagnostic ignored "-Wnon-virtual-dtor" | ||
| 293 | +#pragma GCC diagnostic ignored "-Weffc++" | ||
| 293 | // This will be ignored under other compilers like LLVM clang. | 294 | // This will be ignored under other compilers like LLVM clang. |
| 294 | #endif | 295 | #endif |
| 295 | class Value : public std::enable_shared_from_this<Value> | 296 | class Value : public std::enable_shared_from_this<Value> |