]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
build: enable gcc-12/13+, clang-10+ picky warnings
authorViktor Szakats <commit@vsz.me>
Sat, 26 Apr 2025 07:28:28 +0000 (09:28 +0200)
committerViktor Szakats <commit@vsz.me>
Sat, 26 Apr 2025 10:59:54 +0000 (12:59 +0200)
Cherry-picked from #17190
Closes #17196

CMake/PickyWarnings.cmake
m4/curl-compilers.m4

index 610def004d433810f5d52d162d3e3790e31dc261..061e7a7a17c6879e8a9571cf9b8775b802a2516a 100644 (file)
@@ -179,6 +179,7 @@ if(PICKY_COMPILER)
          (CMAKE_C_COMPILER_ID STREQUAL "AppleClang" AND CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 12.4))
         list(APPEND _picky_enable
           -Wimplicit-fallthrough           # clang  4.0  gcc  7.0  appleclang 12.4  # We do silencing for clang 10.0 and above only
+          -Wxor-used-as-pow                # clang 10.0  gcc 13.0
         )
       endif()
     else()  # gcc
@@ -242,6 +243,13 @@ if(PICKY_COMPILER)
           -Wenum-conversion                # clang  3.2  gcc 10.0  appleclang  4.6  g++ 11.0
         )
       endif()
+      if(CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 13.0)
+        list(APPEND _picky_enable
+          -Warray-compare                  # clang 20.0  gcc 12.0
+          -Wenum-int-mismatch              #             gcc 13.0
+          -Wxor-used-as-pow                # clang 10.0  gcc 13.0
+        )
+      endif()
     endif()
 
     #
index 15babf9d30eb370373ccc6320fb4b18bf2e4469f..df4b9a266ca831d8670bee68b2bc596c6d917a5a 100644 (file)
@@ -905,6 +905,7 @@ AC_DEFUN([CURL_SET_COMPILER_WARNING_OPTS], [
           dnl clang 10 or later
           if test "$compiler_num" -ge "1000"; then
             tmp_CFLAGS="$tmp_CFLAGS -Wimplicit-fallthrough"  # we have silencing markup for clang 10.0 and above only
+            CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [xor-used-as-pow])
           fi
         fi
         ;;
@@ -1096,6 +1097,17 @@ AC_DEFUN([CURL_SET_COMPILER_WARNING_OPTS], [
             CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [enum-conversion])
           fi
           #
+          dnl Only gcc 12 or later
+          if test "$compiler_num" -ge "1200"; then
+            CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [array-compare])
+          fi
+          #
+          dnl Only gcc 13 or later
+          if test "$compiler_num" -ge "1300"; then
+            CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [enum-int-mismatch])
+            CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [xor-used-as-pow])
+          fi
+          #
         fi
         #
         dnl Do not issue warnings for code in system include paths.