Skip to content

Commit

Permalink
add new warning options to the CMakeLists.txt and update code
Browse files Browse the repository at this point in the history
  • Loading branch information
i80287 committed Oct 30, 2024
1 parent 6ab9419 commit 5de01cb
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 11 deletions.
78 changes: 69 additions & 9 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ function(configure_gcc_or_clang_gcc_options)
-Wtype-limits
-Wshift-negative-value
-Walloca
-Wdate-time
-Wdouble-promotion
-Werror
-pedantic-errors
)
Expand Down Expand Up @@ -170,7 +172,6 @@ function(configure_gcc_or_clang_gcc_options)
-Wshift-sign-overflow
-Wshorten-64-to-32
-Wthread-safety
-Wnull-pointer-arithmetic
-Wnullable-to-nonnull-conversion
-Wsometimes-uninitialized
-Wstatic-in-inline
Expand All @@ -183,6 +184,50 @@ function(configure_gcc_or_clang_gcc_options)
-Wimplicit
-Wimplicit-fallthrough
-Winconsistent-missing-destructor-override
-Wabstract-vbase-init
-Warc-repeated-use-of-weak
-Wassign-enum
-Watomic-properties
-Watomic-implicit-seq-cst
-Wbad-function-cast
-Wbind-to-temporary-copy
-Wcast-function-type
-Wcomma
-Wc++-compat
-Wcalled-once-parameter
-Wcompound-token-split
-Wconditional-uninitialized
-Wconsumed
-Wdeprecated-implementations
-Wdirect-ivar-access
-Wdisabled-macro-expansion
# -Wdocumentation # TODO:
-Wdtor-name
-Wduplicate-decl-specifier
-Wduplicate-enum
-Wduplicate-method-arg
-Wduplicate-method-match
-Wexpansion-to-defined # enabled by the -Wextra on gcc
-Wexplicit-ownership-type
-Wloop-analysis
-Wextra-semi
-Wextra-semi-stmt
-Wheader-hygiene
-Wimplicit-retain-self
-Wimport-preprocessor-directive-pedantic
-Winvalid-or-nonexistent-directory
-Wmain # enabled by the -Wpedantic on gcc
-Wmethod-signatures
-Wmicrosoft
-Wnarrowing # enabled by the -Wpedantic on gcc
-Wnewline-eof
-Wover-aligned
-Woverriding-method-mismatch
-Wunguarded-availability
-Wunused-member-function
-Wused-but-marked-unused
-Wvector-conversion
-Wvla
-fcolor-diagnostics
-fansi-escape-codes
-ftemplate-backtrace-limit=0)
Expand All @@ -191,11 +236,6 @@ function(configure_gcc_or_clang_gcc_options)
${LOCAL_FN_TEST_CXX_COMPILE_OPTIONS}
-Wframe-address)
endif()
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 13.0.0)
set(LOCAL_FN_TEST_CXX_COMPILE_OPTIONS
${LOCAL_FN_TEST_CXX_COMPILE_OPTIONS}
-Wnull-pointer-subtraction)
endif()
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 15.0.0)
set(LOCAL_FN_TEST_CXX_COMPILE_OPTIONS
${LOCAL_FN_TEST_CXX_COMPILE_OPTIONS}
Expand Down Expand Up @@ -226,13 +266,27 @@ function(configure_gcc_or_clang_gcc_options)
set(LOCAL_FN_TEST_C_COMPILE_OPTIONS
${LOCAL_FN_TEST_C_COMPILE_OPTIONS}
-Wwrite-strings
-Wbad-function-cast
-Wint-conversion
)
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 11.0.0)
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set(LOCAL_FN_TEST_C_COMPILE_OPTIONS
${LOCAL_FN_TEST_C_COMPILE_OPTIONS}
-fanalyzer
-Wincompatible-pointer-types # TODO: may be turned on by -Wpedantic ?
-Wbad-function-cast # added on the C++ stage if Clang is used
)
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 11.0.0)
set(LOCAL_FN_TEST_C_COMPILE_OPTIONS
${LOCAL_FN_TEST_C_COMPILE_OPTIONS}
-fanalyzer
)
endif()
endif()
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
set(LOCAL_FN_TEST_C_COMPILE_OPTIONS
${LOCAL_FN_TEST_C_COMPILE_OPTIONS}
-Wc11-extensions
-Wc23-compat
-Wc23-extensions
)
endif()
# Flags for C++ only
Expand All @@ -249,6 +303,12 @@ function(configure_gcc_or_clang_gcc_options)
)
endif()
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 16.0.0)
set(LOCAL_FN_TEST_CXX_COMPILE_OPTIONS
${LOCAL_FN_TEST_CXX_COMPILE_OPTIONS}
-Wcomma-subscript
-Wregister
-Wchanges-meaning
)
set(LOCAL_FN_TEST_CXX_COMPILE_OPTIONS
${LOCAL_FN_TEST_CXX_COMPILE_OPTIONS}
-fanalyzer
Expand Down
2 changes: 0 additions & 2 deletions tests/run_codechecker.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#!/usr/bin/env bash

set -e

build_dir=cmake-build-codechecker
cmake_build_dir=cmake-build-dir

Expand Down

0 comments on commit 5de01cb

Please sign in to comment.