build: picky warning updates

- cmake: sync some picky gcc warnings with autotools.
- cmake, autotools: add `-Wold-style-definition` for clang too.
- cmake: more precise version info for old clang options.
- cmake: use `IN LISTS` syntax in `foreach()`.

Reviewed-by: Daniel Stenberg
Reviewed-by: Marcel Raad
Closes #12324
This commit is contained in:
Viktor Szakats 2023-11-15 00:32:43 +00:00
parent 70e3b534d5
commit 033f8e2a08
No known key found for this signature in database
GPG Key ID: B5ABD165E2AEF201
2 changed files with 12 additions and 9 deletions

View File

@ -52,8 +52,8 @@ if(PICKY_COMPILER)
# Assume these options always exist with both clang and gcc.
# Require clang 3.0 / gcc 2.95 or later.
list(APPEND WPICKY_ENABLE
-Wbad-function-cast # clang 3.0 gcc 2.95
-Wconversion # clang 3.0 gcc 2.95
-Wbad-function-cast # clang 2.7 gcc 2.95
-Wconversion # clang 2.7 gcc 2.95
-Winline # clang 1.0 gcc 1.0
-Wmissing-declarations # clang 1.0 gcc 2.7
-Wmissing-prototypes # clang 1.0 gcc 1.0
@ -72,15 +72,16 @@ if(PICKY_COMPILER)
set(WPICKY_COMMON_OLD
-Wcast-align # clang 1.0 gcc 4.2
-Wdeclaration-after-statement # clang 1.0 gcc 3.4
-Wempty-body # clang 3.0 gcc 4.3
-Wempty-body # clang 2.7 gcc 4.3
-Wendif-labels # clang 1.0 gcc 3.3
-Wfloat-equal # clang 1.0 gcc 2.96 (3.0)
-Wignored-qualifiers # clang 3.0 gcc 4.3
-Wignored-qualifiers # clang 2.8 gcc 4.3
-Wno-format-nonliteral # clang 1.0 gcc 2.96 (3.0)
-Wno-sign-conversion # clang 3.0 gcc 4.3
-Wno-sign-conversion # clang 2.9 gcc 4.3
-Wno-system-headers # clang 1.0 gcc 3.0
-Wold-style-definition # clang 2.7 gcc 3.4
-Wstrict-prototypes # clang 1.0 gcc 3.3
-Wtype-limits # clang 3.0 gcc 4.3
-Wtype-limits # clang 2.7 gcc 4.3
-Wvla # clang 2.8 gcc 4.3
)
@ -125,6 +126,7 @@ if(PICKY_COMPILER)
if(NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.3)
list(APPEND WPICKY_ENABLE
${WPICKY_COMMON_OLD}
-Wclobbered # gcc 4.3
-Wmissing-parameter-type # gcc 4.3
-Wold-style-declaration # gcc 4.3
-Wstrict-aliasing=3 # gcc 4.0
@ -159,7 +161,7 @@ if(PICKY_COMPILER)
-Walloc-zero # gcc 7.0
-Wduplicated-branches # gcc 7.0
-Wformat-overflow=2 # gcc 7.0
-Wformat-truncation=1 # gcc 7.0
-Wformat-truncation=2 # gcc 7.0
-Wrestrict # gcc 7.0
)
endif()
@ -174,11 +176,11 @@ if(PICKY_COMPILER)
unset(WPICKY)
foreach(_CCOPT ${WPICKY_ENABLE})
foreach(_CCOPT IN LISTS WPICKY_ENABLE)
set(WPICKY "${WPICKY} ${_CCOPT}")
endforeach()
foreach(_CCOPT ${WPICKY_DETECT})
foreach(_CCOPT IN LISTS WPICKY_DETECT)
# surprisingly, CHECK_C_COMPILER_FLAG needs a new variable to store each new
# test result in.
string(MAKE_C_IDENTIFIER "OPT${_CCOPT}" _optvarname)

View File

@ -764,6 +764,7 @@ AC_DEFUN([CURL_SET_COMPILER_WARNING_OPTS], [
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [inline nested-externs])
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [missing-declarations])
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [missing-prototypes])
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [old-style-definition])
tmp_CFLAGS="$tmp_CFLAGS -Wno-long-long"
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [float-equal])
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [no-multichar sign-compare])