aligned GCC warnings (#2592)

* excluded oss-fuzz related CMake targets from all

* checkstl.cpp: fixed -Wmissing-declarations warning

* suppress -Wsuggest-attribute=format GCC warnings for tinyxml in CMake for now

* aligned GCC warnings in dmake, CMake and Travis / removed now useless WARNINGS_ANSI_ISO
This commit is contained in:
Oliver Stöneberg 2020-04-08 14:56:12 +02:00 committed by GitHub
parent 10269a5286
commit e3b644d877
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 16 additions and 33 deletions

View File

@ -7,7 +7,7 @@ compiler:
env:
global:
- ORIGINAL_CXXFLAGS="-pedantic -Wall -Wextra -Wabi -Wcast-qual -Wfloat-equal -Wmissing-declarations -Wmissing-format-attribute -Wno-long-long -Wpacked -Wredundant-decls -Wno-shadow -Wno-missing-field-initializers -Wno-missing-braces -Wno-sign-compare -Wno-multichar -D_GLIBCXX_DEBUG -g "
- ORIGINAL_CXXFLAGS="-pedantic -Wall -Wextra -Wcast-qual -Wno-deprecated-declarations -Wfloat-equal -Wmissing-declarations -Wmissing-format-attribute -Wno-long-long -Wpacked -Wredundant-decls -Wundef -Wno-shadow -Wno-missing-field-initializers -Wno-missing-braces -Wno-sign-compare -Wno-multichar -D_GLIBCXX_DEBUG -g "
# unfortunately we need this to stay within 50min timelimit given by travis.
- CXXFLAGS="${ORIGINAL_CXXFLAGS} -O2 -march=native -Wstrict-aliasing=2 -Werror=strict-aliasing"
- CPPCHECK=${TRAVIS_BUILD_DIR}/cppcheck

View File

@ -12,7 +12,7 @@ if (USE_CLANG)
set (CMAKE_C_FLAGS_DEBUG "-g")
set (CMAKE_C_FLAGS_RELEASE "-O2")
set (CMAKE_CXX_FLAGS "")
set (CMAKE_CXX_FLAGS "-pedantic -Wall -Wextra")
set (CMAKE_CXX_FLAGS_DEBUG "-g")
set (CMAKE_CXX_FLAGS_RELEASE "-O2")
endif()
@ -27,7 +27,7 @@ if (USE_ANALYZE)
set (CMAKE_C_FLAGS_DEBUG "-g")
set (CMAKE_C_FLAGS_RELEASE "-O2")
set (CMAKE_CXX_FLAGS "-Wall")
set (CMAKE_CXX_FLAGS "-pedantic -Wall -Wextra")
set (CMAKE_CXX_FLAGS_DEBUG "-g")
set (CMAKE_CXX_FLAGS_RELEASE "-O2")
endif()
@ -43,28 +43,20 @@ if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
endif ()
set(EXTRA_C_FLAGS "${EXTRA_C_FLAGS} -Wcast-qual") # Cast for removing type qualifiers
set(EXTRA_C_FLAGS "${EXTRA_C_FLAGS} -Wno-conversion") # Implicit conversions that may alter a value
set(EXTRA_C_FLAGS "${EXTRA_C_FLAGS} -Wno-deprecated-declarations")
set(EXTRA_C_FLAGS "${EXTRA_C_FLAGS} -Wfloat-equal") # Floating values used in equality comparisons
set(EXTRA_C_FLAGS "${EXTRA_C_FLAGS} -Wmissing-declarations") # If a global function is defined without a previous declaration
set(EXTRA_C_FLAGS "${EXTRA_C_FLAGS} -Wmissing-format-attribute") #
set(EXTRA_C_FLAGS "${EXTRA_C_FLAGS} -Wno-long-long")
set(EXTRA_C_FLAGS "${EXTRA_C_FLAGS} -Woverloaded-virtual") # when a function declaration hides virtual functions from a base class
set(EXTRA_C_FLAGS "${EXTRA_C_FLAGS} -Wpacked") #
set(EXTRA_C_FLAGS "${EXTRA_C_FLAGS} -Wredundant-decls") # if anything is declared more than once in the same scope
set(EXTRA_C_FLAGS "${EXTRA_C_FLAGS} -Wundef")
set(EXTRA_C_FLAGS "${EXTRA_C_FLAGS} -Wno-shadow") # whenever a local variable or type declaration shadows another one
set(EXTRA_C_FLAGS "${EXTRA_C_FLAGS} -Wno-sign-promo") #
set(EXTRA_C_FLAGS "${EXTRA_C_FLAGS} -Wno-missing-field-initializers")
set(EXTRA_C_FLAGS "${EXTRA_C_FLAGS} -Wno-missing-braces")
set(EXTRA_C_FLAGS "${EXTRA_C_FLAGS} -Wno-sign-compare")
if(WARNINGS_ANSI_ISO)
# set(EXTRA_C_FLAGS "${EXTRA_C_FLAGS} -Werror=return-type") #
# set(EXTRA_C_FLAGS "${EXTRA_C_FLAGS} -Wstrict-aliasing=3")
else()
set(EXTRA_C_FLAGS "${EXTRA_C_FLAGS} -Wno-narrowing")
set(EXTRA_C_FLAGS "${EXTRA_C_FLAGS} -Wno-delete-non-virtual-dtor")
set(EXTRA_C_FLAGS "${EXTRA_C_FLAGS} -Wno-unnamed-type-template-args")
endif()
set(EXTRA_C_FLAGS "${EXTRA_C_FLAGS} -Wno-multichar")
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
if(NOT EXISTS ${CMAKE_CXX_COMPILER})
@ -98,20 +90,11 @@ if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR
"${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR
"${CMAKE_CXX_COMPILER_ID}" STREQUAL "c++-analyzer" )
if(WARNINGS_ANSI_ISO)
set(EXTRA_C_FLAGS "-Wextra -pedantic ${EXTRA_C_FLAGS}")
# set(EXTRA_C_FLAGS "${EXTRA_C_FLAGS} -Wlogical-op")
set(EXTRA_C_FLAGS "${EXTRA_C_FLAGS} -Wno-long-long") # Don't warn about long long usage.
endif()
if(WARNINGS_ARE_ERRORS)
set(EXTRA_C_FLAGS "${EXTRA_C_FLAGS} -Werror")
endif()
set(EXTRA_C_FLAGS "-Wall ${EXTRA_C_FLAGS}")
set(EXTRA_C_FLAGS_DEBUG "${EXTRA_C_FLAGS_DEBUG} -O0")
endif()
if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux" AND

View File

@ -21,7 +21,6 @@ option(ANALYZE_THREAD "Clang dynamic analyzer: tool that detects data race
option(ANALYZE_UNDEFINED "Clang dynamic analyzer: undefined behavior checker. " OFF)
option(ANALYZE_DATAFLOW "Clang dynamic analyzer: general dynamic dataflow analysis." OFF)
option(WARNINGS_ARE_ERRORS "Treat warnings as errors" OFF)
option(WARNINGS_ANSI_ISO "Issue all the mandatory diagnostics Listed in C standard" ON)
set(USE_MATCHCOMPILER "Auto" CACHE STRING "Usage of match compiler")
set_property(CACHE USE_MATCHCOMPILER PROPERTY STRINGS Auto Off On Verify)

View File

@ -20,7 +20,6 @@ message( STATUS "ANALYZE_ADDRESS = ${ANALYZE_ADDRESS}" )
message( STATUS "ANALYZE_THREAD = ${ANALYZE_THREAD}" )
message( STATUS "ANALYZE_UNDEFINED = ${ANALYZE_UNDEFINED}" )
message( STATUS "ANALYZE_DATAFLOW = ${ANALYZE_DATAFLOW}" )
message( STATUS "WARNINGS_ANSI_ISO = ${WARNINGS_ANSI_ISO}" )
message( STATUS "WARNINGS_ARE_ERRORS = ${WARNINGS_ARE_ERRORS}" )
message( STATUS )
message( STATUS "USE_MATCHCOMPILER = ${USE_MATCHCOMPILER}" )

View File

@ -2,9 +2,11 @@ file(GLOB hdrs "*.h")
file(GLOB srcs "*.cpp")
add_library(tinyxml_objs OBJECT ${srcs} ${hdrs})
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU")
# TODO: needs to be fixed upstream
target_compile_options(tinyxml_objs PRIVATE -Wno-suggest-attribute=format)
endif()
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_library(tinyxml_objs_sanitized OBJECT ${srcs} ${hdrs})
target_compile_options(tinyxml_objs_sanitized PRIVATE -fsanitize=address)
endif()

View File

@ -846,7 +846,7 @@ void CheckStl::invalidContainer()
}
}
const Token* getLoopContainer(const Token* tok)
static const Token* getLoopContainer(const Token* tok)
{
if (!Token::simpleMatch(tok, "for ("))
return nullptr;

View File

@ -1,5 +1,5 @@
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_executable(fuzz-client
add_executable(fuzz-client EXCLUDE_FROM_ALL
main.cpp
type2.cpp)
target_include_directories(fuzz-client PRIVATE ${CMAKE_SOURCE_DIR}/lib ${CMAKE_SOURCE_DIR}/externals/simplecpp ${CMAKE_SOURCE_DIR}/externals/tinyxml ${CMAKE_SOURCE_DIR}/externals)
@ -9,7 +9,7 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
#target_link_options(fuzz-client PRIVATE -fsanitize=address -fsanitize=fuzzer)
target_link_libraries(fuzz-client PRIVATE -fsanitize=address -fsanitize=fuzzer)
add_executable(translate
add_executable(translate EXCLUDE_FROM_ALL
translate.cpp
type2.cpp)
endif()