build: replace -pedantic with -Wpedantic when supported

To use the modern form when possible. The modern option also allows
using the `no-` prefix to disable.

Supported by: gcc 4.8+, clang 3.2+ (= appleclang 4.2+)

This also automatically changes `-clang:-pedantic` to `-Wpedantic` in
clang-cl builds.

Refs:
9877f689f2
https://gcc.gnu.org/onlinedocs/gcc-4.8.5/gcc/Warning-Options.html

Closes #20010
This commit is contained in:
Viktor Szakats 2025-12-17 15:13:12 +01:00
parent 9cd827a226
commit 7e2b15ee56
No known key found for this signature in database
GPG key ID: B5ABD165E2AEF201
2 changed files with 20 additions and 6 deletions

View file

@ -796,7 +796,11 @@ AC_DEFUN([CURL_SET_COMPILER_WARNING_OPTS], [
CLANG|APPLECLANG)
#
if test "$want_warnings" = "yes"; then
tmp_CFLAGS="$tmp_CFLAGS -pedantic"
if test "$compiler_num" -ge "302"; then
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [pedantic])
else
tmp_CFLAGS="$tmp_CFLAGS -pedantic"
fi
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [all extra])
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [pointer-arith write-strings])
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [shadow])
@ -974,8 +978,12 @@ AC_DEFUN([CURL_SET_COMPILER_WARNING_OPTS], [
dnl Do not enable -pedantic when cross-compiling with a gcc older
dnl than 3.0, to avoid warnings from third party system headers.
if test "$cross_compiling" != "yes" ||
test "$compiler_num" -ge "300"; then
tmp_CFLAGS="$tmp_CFLAGS -pedantic"
test "$compiler_num" -ge "300"; then
if test "$compiler_num" -ge "408"; then
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [pedantic])
else
tmp_CFLAGS="$tmp_CFLAGS -pedantic"
fi
fi
#
dnl Set of options we believe *ALL* gcc versions support: