improved compiler warnings about missing attributes (#3232)
This commit is contained in:
parent
4f43dbf954
commit
dcc90c6dfa
|
@ -7,6 +7,13 @@ function(add_compile_options_safe FLAG)
|
||||||
endif()
|
endif()
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
|
function(target_compile_options_safe TARGET FLAG)
|
||||||
|
check_cxx_compiler_flag(${FLAG} _has_flag)
|
||||||
|
if (_has_flag)
|
||||||
|
target_compile_options(${TARGET} PRIVATE ${FLAG})
|
||||||
|
endif()
|
||||||
|
endfunction()
|
||||||
|
|
||||||
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||||
if(CMAKE_BUILD_TYPE MATCHES "Release")
|
if(CMAKE_BUILD_TYPE MATCHES "Release")
|
||||||
# "Release" uses -O3 by default
|
# "Release" uses -O3 by default
|
||||||
|
@ -41,6 +48,7 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "GNU")
|
||||||
|
|
||||||
add_compile_options(-Woverloaded-virtual) # when a function declaration hides virtual functions from a base class
|
add_compile_options(-Woverloaded-virtual) # when a function declaration hides virtual functions from a base class
|
||||||
add_compile_options(-Wno-maybe-uninitialized) # there are some false positives
|
add_compile_options(-Wno-maybe-uninitialized) # there are some false positives
|
||||||
|
add_compile_options(-Wsuggest-attribute=noreturn)
|
||||||
elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||||
|
|
||||||
add_compile_options(-Wno-four-char-constants)
|
add_compile_options(-Wno-four-char-constants)
|
||||||
|
@ -52,6 +60,7 @@ elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||||
add_compile_options_safe(-Wdocumentation-pedantic)
|
add_compile_options_safe(-Wdocumentation-pedantic)
|
||||||
add_compile_options_safe(-Wno-documentation-unknown-command)
|
add_compile_options_safe(-Wno-documentation-unknown-command)
|
||||||
add_compile_options_safe(-Wimplicit-fallthrough)
|
add_compile_options_safe(-Wimplicit-fallthrough)
|
||||||
|
add_compile_options_safe(-Wmissing-noreturn)
|
||||||
|
|
||||||
if(ENABLE_COVERAGE OR ENABLE_COVERAGE_XML)
|
if(ENABLE_COVERAGE OR ENABLE_COVERAGE_XML)
|
||||||
message(FATAL_ERROR "Do not use clang for generate code coverage. Use gcc.")
|
message(FATAL_ERROR "Do not use clang for generate code coverage. Use gcc.")
|
||||||
|
|
|
@ -3,13 +3,12 @@ file(GLOB srcs "*.cpp")
|
||||||
|
|
||||||
add_library(tinyxml2_objs OBJECT ${srcs} ${hdrs})
|
add_library(tinyxml2_objs OBJECT ${srcs} ${hdrs})
|
||||||
|
|
||||||
# TODO: need to be fixed upstream
|
# TODO: needs to be fixed upstream
|
||||||
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU")
|
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU")
|
||||||
target_compile_options(tinyxml2_objs PRIVATE -Wno-suggest-attribute=format)
|
target_compile_options(tinyxml2_objs PRIVATE -Wno-suggest-attribute=format)
|
||||||
endif()
|
endif()
|
||||||
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||||
if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS "8.0.0")
|
target_compile_options_safe(tinyxml2_objs -Wno-extra-semi-stmt)
|
||||||
target_compile_options(tinyxml2_objs PRIVATE -Wno-extra-semi-stmt)
|
target_compile_options_safe(tinyxml2_objs -Wno-implicit-fallthrough)
|
||||||
endif()
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
|
@ -451,7 +451,7 @@ private:
|
||||||
static bool removeTemplate(Token *tok);
|
static bool removeTemplate(Token *tok);
|
||||||
|
|
||||||
/** Syntax error */
|
/** Syntax error */
|
||||||
static void syntaxError(const Token *tok);
|
NORETURN static void syntaxError(const Token *tok);
|
||||||
|
|
||||||
static bool matchSpecialization(
|
static bool matchSpecialization(
|
||||||
const Token *templateDeclarationNameToken,
|
const Token *templateDeclarationNameToken,
|
||||||
|
|
|
@ -617,7 +617,7 @@ private:
|
||||||
* Send error message to error logger about internal bug.
|
* Send error message to error logger about internal bug.
|
||||||
* @param tok the token that this bug concerns.
|
* @param tok the token that this bug concerns.
|
||||||
*/
|
*/
|
||||||
void cppcheckError(const Token *tok) const;
|
NORETURN void cppcheckError(const Token *tok) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Setup links for tokens so that one can call Token::link().
|
* Setup links for tokens so that one can call Token::link().
|
||||||
|
|
Loading…
Reference in New Issue