diff --git a/CMakeLists.txt b/CMakeLists.txt index c87bc17b38c..3eee64ec288 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -104,6 +104,12 @@ if(CMAKE_C_COMPILER_ID MATCHES "GNU") list(APPEND c_compile_options "-Wno-old-style-declaration") endif() +# TODO IDF-15784: remove in IDF v7.0 ? +check_c_compiler_flag("-Wunused-but-set-variable=1" compiler_supports_wunused_but_set_variable_eq_1) +if(compiler_supports_wunused_but_set_variable_eq_1) + list(APPEND compile_options "-Wunused-but-set-variable=1") +endif() + # Clang finds some warnings in IDF code which GCC doesn't. # All these warnings should be fixed before Clang is presented # as a toolchain choice for users. diff --git a/tools/ci/configure_ci_environment.sh b/tools/ci/configure_ci_environment.sh index 54f2e03159f..38f093cbe03 100644 --- a/tools/ci/configure_ci_environment.sh +++ b/tools/ci/configure_ci_environment.sh @@ -17,8 +17,17 @@ DEBUG_SHELL=${DEBUG_SHELL:-"0"} # (Depends on default options '-Wno-error=XXX' used in the IDF build system) if [ "$IDF_TOOLCHAIN" != "clang" ]; then - PEDANTIC_FLAGS="-Werror -Werror=deprecated-declarations -Werror=unused-variable -Werror=unused-but-set-variable -Werror=unused-function" + PEDANTIC_FLAGS="-Werror -Werror=deprecated-declarations -Werror=unused-variable -Werror=unused-function" export PEDANTIC_CFLAGS="${PEDANTIC_FLAGS} -Wstrict-prototypes" + # TODO IDF-15784 + case "$CI_JOB_NAME" in + test_pytest_linux|test_sockets_on_host|test_transport_on_host|test_pytest_macos) + export PEDANTIC_CFLAGS="${PEDANTIC_CFLAGS} -Werror=unused-but-set-variable" + ;; + *) + export PEDANTIC_CFLAGS="${PEDANTIC_CFLAGS} -Werror=unused-but-set-variable=1" + ;; + esac else export PEDANTIC_CFLAGS="-Werror" fi diff --git a/tools/cmakev2/project.cmake b/tools/cmakev2/project.cmake index 22189e962aa..7aa49957a79 100644 --- a/tools/cmakev2/project.cmake +++ b/tools/cmakev2/project.cmake @@ -236,6 +236,12 @@ function(__init_project_configuration) list(APPEND c_compile_options "-Wno-old-style-declaration") endif() + # TODO IDF-15784: remove in IDF v7.0 ? + check_c_compiler_flag("-Wunused-but-set-variable=1" compiler_supports_wunused_but_set_variable_eq_1) + if(compiler_supports_wunused_but_set_variable_eq_1) + list(APPEND compile_options "-Wunused-but-set-variable=1") + endif() + # Clang finds some warnings in IDF code which GCC doesn't. # All these warnings should be fixed before Clang is presented # as a toolchain choice for users.