Skip to content

Commit

Permalink
build: picky warning updates
Browse files Browse the repository at this point in the history
- cmake, autotools: sync picky gcc warnings with curl.
- cmake, autotools: add `-Wold-style-definition` for clang too.
- cmake, autotools: add comment for `-Wformat-truncation=1`.
- cmake: more precise version info for old clang options.

Closes #1219
  • Loading branch information
vszakats committed Nov 15, 2023
1 parent fea6664 commit 328a96b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
6 changes: 4 additions & 2 deletions acinclude.m4
Expand Up @@ -215,6 +215,7 @@ AC_DEFUN([CURL_CC_DEBUG_OPTS],
CURL_ADD_COMPILER_WARNINGS([WARN], [inline nested-externs])
CURL_ADD_COMPILER_WARNINGS([WARN], [missing-declarations])
CURL_ADD_COMPILER_WARNINGS([WARN], [missing-prototypes])
CURL_ADD_COMPILER_WARNINGS([WARN], [old-style-definition])
WARN="$WARN -Wno-long-long"
CURL_ADD_COMPILER_WARNINGS([WARN], [float-equal])
CURL_ADD_COMPILER_WARNINGS([WARN], [no-multichar sign-compare])
Expand Down Expand Up @@ -362,6 +363,7 @@ AC_DEFUN([CURL_CC_DEBUG_OPTS],
if test "$compiler_num" -ge "304"; then
# try these on gcc 3.4
WARN="$WARN -Wdeclaration-after-statement"
WARN="$WARN -Wold-style-definition"
fi
dnl Only gcc 4.0 or later
Expand All @@ -383,7 +385,7 @@ AC_DEFUN([CURL_CC_DEBUG_OPTS],
if test "$compiler_num" -ge "403"; then
CURL_ADD_COMPILER_WARNINGS([WARN], [type-limits old-style-declaration])
CURL_ADD_COMPILER_WARNINGS([WARN], [missing-parameter-type empty-body])
CURL_ADD_COMPILER_WARNINGS([WARN], [ignored-qualifiers])
CURL_ADD_COMPILER_WARNINGS([WARN], [clobbered ignored-qualifiers])
CURL_ADD_COMPILER_WARNINGS([WARN], [conversion])
WARN="$WARN -Wno-sign-conversion"
CURL_ADD_COMPILER_WARNINGS([WARN], [vla])
Expand Down Expand Up @@ -432,7 +434,7 @@ AC_DEFUN([CURL_CC_DEBUG_OPTS],
CURL_ADD_COMPILER_WARNINGS([WARN], [restrict])
CURL_ADD_COMPILER_WARNINGS([WARN], [alloc-zero])
WARN="$WARN -Wformat-overflow=2"
WARN="$WARN -Wformat-truncation=1"
WARN="$WARN -Wformat-truncation=1" # =2 causes false positives
fi
#
dnl Only gcc 10 or later
Expand Down
16 changes: 9 additions & 7 deletions cmake/max_warnings.cmake
Expand Up @@ -67,8 +67,8 @@ elseif(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX OR CMAKE_C_COMPILER_I
# 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
Expand All @@ -87,15 +87,16 @@ elseif(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX OR CMAKE_C_COMPILER_I
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
)

Expand Down Expand Up @@ -140,6 +141,7 @@ elseif(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX OR CMAKE_C_COMPILER_I
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
Expand Down Expand Up @@ -174,7 +176,7 @@ elseif(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX OR CMAKE_C_COMPILER_I
-Walloc-zero # gcc 7.0
-Wduplicated-branches # gcc 7.0
-Wformat-overflow=2 # gcc 7.0
-Wformat-truncation=1 # gcc 7.0
-Wformat-truncation=1 # gcc 7.0 (=2 causes false positives)
-Wrestrict # gcc 7.0
)
endif()
Expand Down

0 comments on commit 328a96b

Please sign in to comment.