1
0
mirror of https://github.com/libssh2/libssh2.git synced 2025-11-18 15:20:56 +03:00

acinclude.m4: fix indentation [ci skip]

Also match indentation of curl's `m4/curl-compilers.m4` for
easier syncing.
This commit is contained in:
Viktor Szakats
2023-11-15 22:51:41 +00:00
parent ce5f208a55
commit e645fa95f3

View File

@@ -151,24 +151,24 @@ dnl sets the $ICC variable to "yes" or "no"
dnl ********************************************************************** dnl **********************************************************************
AC_DEFUN([CURL_DETECT_ICC], AC_DEFUN([CURL_DETECT_ICC],
[ [
ICC="no" ICC="no"
AC_MSG_CHECKING([for icc in use]) AC_MSG_CHECKING([for icc in use])
if test "$GCC" = "yes"; then if test "$GCC" = "yes"; then
dnl check if this is icc acting as gcc in disguise dnl check if this is icc acting as gcc in disguise
AC_EGREP_CPP([^__INTEL_COMPILER], [__INTEL_COMPILER], AC_EGREP_CPP([^__INTEL_COMPILER], [__INTEL_COMPILER],
dnl action if the text is found, this it has not been replaced by the dnl action if the text is found, this it has not been replaced by the
dnl cpp dnl cpp
ICC="no", ICC="no",
dnl the text was not found, it was replaced by the cpp dnl the text was not found, it was replaced by the cpp
ICC="yes" ICC="yes"
AC_MSG_RESULT([yes]) AC_MSG_RESULT([yes])
[$1] [$1]
) )
fi fi
if test "$ICC" = "no"; then if test "$ICC" = "no"; then
# this is not ICC # this is not ICC
AC_MSG_RESULT([no]) AC_MSG_RESULT([no])
fi fi
]) ])
dnl We create a function for detecting which compiler we use and then set as dnl We create a function for detecting which compiler we use and then set as
@@ -177,319 +177,323 @@ dnl options are only used for debug-builds.
AC_DEFUN([CURL_CC_DEBUG_OPTS], AC_DEFUN([CURL_CC_DEBUG_OPTS],
[ [
if test "z$CLANG" = "z"; then if test "z$CLANG" = "z"; then
CURL_CHECK_COMPILER_CLANG CURL_CHECK_COMPILER_CLANG
if test "z$compiler_id" = "zCLANG"; then if test "z$compiler_id" = "zCLANG"; then
CLANG="yes" CLANG="yes"
else else
CLANG="no" CLANG="no"
fi
fi
if test "z$ICC" = "z"; then
CURL_DETECT_ICC
fi fi
fi
if test "z$ICC" = "z"; then
CURL_DETECT_ICC
fi
if test "$CLANG" = "yes"; then if test "$CLANG" = "yes"; then
dnl figure out clang version! # indentation to match curl's m4/curl-compilers.m4
AC_MSG_CHECKING([clang version])
fullclangver=`$CC -v 2>&1 | grep version`
clangver=`echo $fullclangver | grep "based on LLVM " | "$SED" 's/.*(based on LLVM \(@<:@0-9@:>@*\.@<:@0-9@:>@*\).*)/\1/'`
if test -z "$clangver"; then
if echo $fullclangver | grep "Apple LLVM version " >/dev/null; then
dnl Starting with Xcode 7 / clang 3.7, Apple clang won't tell its upstream version
clangver="3.7"
else
clangver=`echo $fullclangver | "$SED" 's/.*version \(@<:@0-9@:>@*\.@<:@0-9@:>@*\).*/\1/'`
fi
fi
clangvhi=`echo $clangver | cut -d . -f1`
clangvlo=`echo $clangver | cut -d . -f2`
compiler_num=`(expr $clangvhi "*" 100 + $clangvlo) 2>/dev/null`
AC_MSG_RESULT($compiler_num)
tmp_CFLAGS="-pedantic" dnl figure out clang version!
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [all extra]) AC_MSG_CHECKING([clang version])
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [pointer-arith write-strings]) fullclangver=`$CC -v 2>&1 | grep version`
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [shadow]) clangver=`echo $fullclangver | grep "based on LLVM " | "$SED" 's/.*(based on LLVM \(@<:@0-9@:>@*\.@<:@0-9@:>@*\).*)/\1/'`
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [inline nested-externs]) if test -z "$clangver"; then
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [missing-declarations]) if echo $fullclangver | grep "Apple LLVM version " >/dev/null; then
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [missing-prototypes]) dnl Starting with Xcode 7 / clang 3.7, Apple clang won't tell its upstream version
tmp_CFLAGS="$tmp_CFLAGS -Wno-long-long" clangver="3.7"
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [float-equal]) else
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [sign-compare]) clangver=`echo $fullclangver | "$SED" 's/.*version \(@<:@0-9@:>@*\.@<:@0-9@:>@*\).*/\1/'`
tmp_CFLAGS="$tmp_CFLAGS -Wno-multichar" fi
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [undef]) fi
tmp_CFLAGS="$tmp_CFLAGS -Wno-format-nonliteral" clangvhi=`echo $clangver | cut -d . -f1`
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [endif-labels strict-prototypes]) clangvlo=`echo $clangver | cut -d . -f2`
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [declaration-after-statement]) compiler_num=`(expr $clangvhi "*" 100 + $clangvlo) 2>/dev/null`
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [cast-align]) AC_MSG_RESULT($compiler_num)
tmp_CFLAGS="$tmp_CFLAGS -Wno-system-headers"
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [shorten-64-to-32])
#
dnl Only clang 1.1 or later
if test "$compiler_num" -ge "101"; then
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [unused])
fi
#
dnl Only clang 2.7 or later
if test "$compiler_num" -ge "207"; then
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [bad-function-cast])
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [conversion])
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [empty-body])
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [old-style-definition])
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [type-limits])
fi
#
dnl Only clang 2.8 or later
if test "$compiler_num" -ge "208"; then
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [ignored-qualifiers])
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [vla])
fi
#
dnl Only clang 2.9 or later
if test "$compiler_num" -ge "209"; then
tmp_CFLAGS="$tmp_CFLAGS -Wno-sign-conversion"
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [shift-sign-overflow])
fi
#
dnl Only clang 3.0 or later (possibly earlier)
if test "$compiler_num" -ge "300"; then
tmp_CFLAGS="$tmp_CFLAGS"
fi
#
dnl Only clang 3.2 or later
if test "$compiler_num" -ge "302"; then
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [enum-conversion])
case $host_os in
cygwin* | mingw*)
dnl skip missing-variable-declarations warnings for cygwin and
dnl mingw because the libtool wrapper executable causes them
;;
*)
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [missing-variable-declarations])
;;
esac
fi
#
dnl Only clang 3.4 or later
if test "$compiler_num" -ge "304"; then
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [unused-const-variable])
fi
#
dnl Only clang 3.6 or later
if test "$compiler_num" -ge "306"; then
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [double-promotion])
fi
#
dnl Only clang 3.9 or later
if test "$compiler_num" -ge "309"; then
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [comma])
# avoid the varargs warning, fixed in 4.0
# https://bugs.llvm.org/show_bug.cgi?id=29140
if test "$compiler_num" -lt "400"; then
tmp_CFLAGS="$tmp_CFLAGS -Wno-varargs"
fi
fi
dnl clang 7 or later
if test "$compiler_num" -ge "700"; then
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [assign-enum])
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [extra-semi-stmt])
fi
CFLAGS="$CFLAGS $tmp_CFLAGS" tmp_CFLAGS="-pedantic"
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [all extra])
AC_MSG_NOTICE([Added this set of compiler options: $tmp_CFLAGS]) CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [pointer-arith write-strings])
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [shadow])
elif test "$GCC" = "yes"; then CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [inline nested-externs])
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [missing-declarations])
dnl figure out gcc version! CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [missing-prototypes])
AC_MSG_CHECKING([gcc version]) tmp_CFLAGS="$tmp_CFLAGS -Wno-long-long"
# strip '-suffix' parts, e.g. Ubuntu Windows cross-gcc returns '10-win32' CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [float-equal])
gccver=`$CC -dumpversion | sed -E 's/-.+$//'` CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [sign-compare])
num1=`echo $gccver | cut -d . -f1` tmp_CFLAGS="$tmp_CFLAGS -Wno-multichar"
num2=`echo $gccver | cut -d . -f2` CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [undef])
compiler_num=`(expr $num1 "*" 100 + $num2) 2>/dev/null` tmp_CFLAGS="$tmp_CFLAGS -Wno-format-nonliteral"
AC_MSG_RESULT($gccver) CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [endif-labels strict-prototypes])
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [declaration-after-statement])
if test "$ICC" = "yes"; then CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [cast-align])
dnl this is icc, not gcc. tmp_CFLAGS="$tmp_CFLAGS -Wno-system-headers"
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [shorten-64-to-32])
dnl ICC warnings we ignore: #
dnl * 269 warns on our "%Od" printf formatters for curl_off_t output: dnl Only clang 1.1 or later
dnl "invalid format string conversion" if test "$compiler_num" -ge "101"; then
dnl * 279 warns on static conditions in while expressions CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [unused])
dnl * 981 warns on "operands are evaluated in unspecified order" fi
dnl * 1418 "external definition with no prior declaration" #
dnl * 1419 warns on "external declaration in primary source file" dnl Only clang 2.7 or later
dnl which we know and do on purpose. if test "$compiler_num" -ge "207"; then
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [bad-function-cast])
tmp_CFLAGS="-wd279,269,981,1418,1419" CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [conversion])
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [empty-body])
if test "$compiler_num" -gt "600"; then CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [old-style-definition])
dnl icc 6.0 and older doesn't have the -Wall flag CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [type-limits])
tmp_CFLAGS="-Wall $tmp_CFLAGS" fi
fi #
else dnl $ICC = yes dnl Only clang 2.8 or later
dnl this is a set of options we believe *ALL* gcc versions support: if test "$compiler_num" -ge "208"; then
tmp_CFLAGS="-W -Wall -Wwrite-strings -pedantic -Wpointer-arith -Wnested-externs -Winline -Wmissing-prototypes" CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [ignored-qualifiers])
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [vla])
if test "$compiler_num" -ge "207"; then fi
dnl gcc 2.7 or later #
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [missing-declarations]) dnl Only clang 2.9 or later
fi if test "$compiler_num" -ge "209"; then
tmp_CFLAGS="$tmp_CFLAGS -Wno-sign-conversion"
if test "$compiler_num" -gt "295"; then CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [shift-sign-overflow])
dnl only if the compiler is newer than 2.95 since we got lots of fi
dnl "`_POSIX_C_SOURCE' is not defined" in system headers with #
dnl gcc 2.95.4 on FreeBSD 4.9! dnl Only clang 3.0 or later (possibly earlier)
tmp_CFLAGS="$tmp_CFLAGS -Wno-long-long -Wno-multichar" if test "$compiler_num" -ge "300"; then
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [bad-function-cast]) tmp_CFLAGS="$tmp_CFLAGS"
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [unused shadow]) fi
fi #
dnl Only clang 3.2 or later
if test "$compiler_num" -ge "296"; then if test "$compiler_num" -ge "302"; then
dnl gcc 2.96 or later CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [enum-conversion])
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [float-equal]) case $host_os in
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [sign-compare]) cygwin* | mingw*)
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [undef]) dnl skip missing-variable-declarations warnings for cygwin and
fi dnl mingw because the libtool wrapper executable causes them
if test "$compiler_num" -gt "296"; then
dnl this option does not exist in 2.96
tmp_CFLAGS="$tmp_CFLAGS -Wno-format-nonliteral"
fi
dnl -Wunreachable-code seems totally unreliable on my gcc 3.3.2 on
dnl on i686-Linux as it gives us heaps with false positives.
dnl Also, on gcc 4.0.X it is totally unbearable and complains all
dnl over making it unusable for generic purposes. Let's not use it.
if test "$compiler_num" -ge "303"; then
dnl gcc 3.3 and later
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [endif-labels strict-prototypes])
fi
if test "$compiler_num" -ge "304"; then
# try these on gcc 3.4
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [declaration-after-statement])
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [old-style-definition])
fi
dnl Only gcc 4.0 or later
if test "$compiler_num" -ge "400"; then
tmp_CFLAGS="$tmp_CFLAGS -Wstrict-aliasing=3"
fi
#
dnl Only gcc 4.1 or later (possibly earlier)
if test "$compiler_num" -ge "401"; then
tmp_CFLAGS="$tmp_CFLAGS -Wno-system-headers"
fi
#
dnl Only gcc 4.2 or later
if test "$compiler_num" -ge "402"; then
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [cast-align])
fi
#
dnl Only gcc 4.3 or later
if test "$compiler_num" -ge "403"; then
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [type-limits old-style-declaration])
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [missing-parameter-type empty-body])
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [clobbered ignored-qualifiers])
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [conversion])
tmp_CFLAGS="$tmp_CFLAGS -Wno-sign-conversion"
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [vla])
dnl required for -Warray-bounds, included in -Wall
tmp_CFLAGS="$tmp_CFLAGS -ftree-vrp"
fi
#
dnl Only gcc 4.5 or later
if test "$compiler_num" -ge "405"; then
dnl Only windows targets
case $host_os in
mingw*)
tmp_CFLAGS="$tmp_CFLAGS -Wno-pedantic-ms-format"
;;
esac
fi
#
dnl Only gcc 4.6 or later
if test "$compiler_num" -ge "406"; then
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [double-promotion])
fi
#
dnl only gcc 4.8 or later
if test "$compiler_num" -ge "408"; then
tmp_CFLAGS="$tmp_CFLAGS -Wformat=2"
fi
#
dnl Only gcc 5 or later
if test "$compiler_num" -ge "500"; then
tmp_CFLAGS="$tmp_CFLAGS -Warray-bounds=2"
fi
#
dnl Only gcc 6 or later
if test "$compiler_num" -ge "600"; then
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [shift-negative-value])
tmp_CFLAGS="$tmp_CFLAGS -Wshift-overflow=2"
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [null-dereference])
tmp_CFLAGS="$tmp_CFLAGS -fdelete-null-pointer-checks"
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [duplicated-cond])
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [unused-const-variable])
fi
#
dnl Only gcc 7 or later
if test "$compiler_num" -ge "700"; then
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [duplicated-branches])
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [restrict])
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [alloc-zero])
tmp_CFLAGS="$tmp_CFLAGS -Wformat-overflow=2"
tmp_CFLAGS="$tmp_CFLAGS -Wformat-truncation=1" # =2 causes false positives
fi
#
dnl Only gcc 10 or later
if test "$compiler_num" -ge "1000"; then
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [arith-conversion])
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [enum-conversion])
fi
for flag in $CPPFLAGS; do
case "$flag" in
-I*)
dnl Include path, provide a -isystem option for the same dir
dnl to prevent warnings in those dirs. The -isystem was not very
dnl reliable on earlier gcc versions.
add=`echo $flag | sed 's/^-I/-isystem /g'`
tmp_CFLAGS="$tmp_CFLAGS $add"
;; ;;
esac *)
done CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [missing-variable-declarations])
;;
esac
fi
#
dnl Only clang 3.4 or later
if test "$compiler_num" -ge "304"; then
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [unused-const-variable])
fi
#
dnl Only clang 3.6 or later
if test "$compiler_num" -ge "306"; then
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [double-promotion])
fi
#
dnl Only clang 3.9 or later
if test "$compiler_num" -ge "309"; then
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [comma])
# avoid the varargs warning, fixed in 4.0
# https://bugs.llvm.org/show_bug.cgi?id=29140
if test "$compiler_num" -lt "400"; then
tmp_CFLAGS="$tmp_CFLAGS -Wno-varargs"
fi
fi
dnl clang 7 or later
if test "$compiler_num" -ge "700"; then
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [assign-enum])
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [extra-semi-stmt])
fi
fi dnl $ICC = no CFLAGS="$CFLAGS $tmp_CFLAGS"
CFLAGS="$CFLAGS $tmp_CFLAGS" AC_MSG_NOTICE([Added this set of compiler options: $tmp_CFLAGS])
AC_MSG_NOTICE([Added this set of compiler options: $tmp_CFLAGS]) elif test "$GCC" = "yes"; then
else dnl $GCC = yes # indentation to match curl's m4/curl-compilers.m4
AC_MSG_NOTICE([Added no extra compiler options]) dnl figure out gcc version!
AC_MSG_CHECKING([gcc version])
# strip '-suffix' parts, e.g. Ubuntu Windows cross-gcc returns '10-win32'
gccver=`$CC -dumpversion | sed -E 's/-.+$//'`
num1=`echo $gccver | cut -d . -f1`
num2=`echo $gccver | cut -d . -f2`
compiler_num=`(expr $num1 "*" 100 + $num2) 2>/dev/null`
AC_MSG_RESULT($gccver)
fi dnl $GCC = yes if test "$ICC" = "yes"; then
dnl this is icc, not gcc.
dnl strip off optimizer flags dnl ICC warnings we ignore:
NEWFLAGS="" dnl * 269 warns on our "%Od" printf formatters for curl_off_t output:
for flag in $CFLAGS; do dnl "invalid format string conversion"
case "$flag" in dnl * 279 warns on static conditions in while expressions
-O*) dnl * 981 warns on "operands are evaluated in unspecified order"
dnl echo "cut off $flag" dnl * 1418 "external definition with no prior declaration"
;; dnl * 1419 warns on "external declaration in primary source file"
*) dnl which we know and do on purpose.
NEWFLAGS="$NEWFLAGS $flag"
;; tmp_CFLAGS="-wd279,269,981,1418,1419"
esac
done if test "$compiler_num" -gt "600"; then
CFLAGS=$NEWFLAGS dnl icc 6.0 and older doesn't have the -Wall flag
tmp_CFLAGS="-Wall $tmp_CFLAGS"
fi
else dnl $ICC = yes
dnl this is a set of options we believe *ALL* gcc versions support:
tmp_CFLAGS="-W -Wall -Wwrite-strings -pedantic -Wpointer-arith -Wnested-externs -Winline -Wmissing-prototypes"
if test "$compiler_num" -ge "207"; then
dnl gcc 2.7 or later
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [missing-declarations])
fi
if test "$compiler_num" -gt "295"; then
dnl only if the compiler is newer than 2.95 since we got lots of
dnl "`_POSIX_C_SOURCE' is not defined" in system headers with
dnl gcc 2.95.4 on FreeBSD 4.9!
tmp_CFLAGS="$tmp_CFLAGS -Wno-long-long -Wno-multichar"
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [bad-function-cast])
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [unused shadow])
fi
if test "$compiler_num" -ge "296"; then
dnl gcc 2.96 or later
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [float-equal])
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [sign-compare])
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [undef])
fi
if test "$compiler_num" -gt "296"; then
dnl this option does not exist in 2.96
tmp_CFLAGS="$tmp_CFLAGS -Wno-format-nonliteral"
fi
dnl -Wunreachable-code seems totally unreliable on my gcc 3.3.2 on
dnl on i686-Linux as it gives us heaps with false positives.
dnl Also, on gcc 4.0.X it is totally unbearable and complains all
dnl over making it unusable for generic purposes. Let's not use it.
if test "$compiler_num" -ge "303"; then
dnl gcc 3.3 and later
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [endif-labels strict-prototypes])
fi
if test "$compiler_num" -ge "304"; then
# try these on gcc 3.4
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [declaration-after-statement])
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [old-style-definition])
fi
dnl Only gcc 4.0 or later
if test "$compiler_num" -ge "400"; then
tmp_CFLAGS="$tmp_CFLAGS -Wstrict-aliasing=3"
fi
#
dnl Only gcc 4.1 or later (possibly earlier)
if test "$compiler_num" -ge "401"; then
tmp_CFLAGS="$tmp_CFLAGS -Wno-system-headers"
fi
#
dnl Only gcc 4.2 or later
if test "$compiler_num" -ge "402"; then
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [cast-align])
fi
#
dnl Only gcc 4.3 or later
if test "$compiler_num" -ge "403"; then
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [type-limits old-style-declaration])
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [missing-parameter-type empty-body])
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [clobbered ignored-qualifiers])
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [conversion])
tmp_CFLAGS="$tmp_CFLAGS -Wno-sign-conversion"
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [vla])
dnl required for -Warray-bounds, included in -Wall
tmp_CFLAGS="$tmp_CFLAGS -ftree-vrp"
fi
#
dnl Only gcc 4.5 or later
if test "$compiler_num" -ge "405"; then
dnl Only windows targets
case $host_os in
mingw*)
tmp_CFLAGS="$tmp_CFLAGS -Wno-pedantic-ms-format"
;;
esac
fi
#
dnl Only gcc 4.6 or later
if test "$compiler_num" -ge "406"; then
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [double-promotion])
fi
#
dnl only gcc 4.8 or later
if test "$compiler_num" -ge "408"; then
tmp_CFLAGS="$tmp_CFLAGS -Wformat=2"
fi
#
dnl Only gcc 5 or later
if test "$compiler_num" -ge "500"; then
tmp_CFLAGS="$tmp_CFLAGS -Warray-bounds=2"
fi
#
dnl Only gcc 6 or later
if test "$compiler_num" -ge "600"; then
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [shift-negative-value])
tmp_CFLAGS="$tmp_CFLAGS -Wshift-overflow=2"
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [null-dereference])
tmp_CFLAGS="$tmp_CFLAGS -fdelete-null-pointer-checks"
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [duplicated-cond])
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [unused-const-variable])
fi
#
dnl Only gcc 7 or later
if test "$compiler_num" -ge "700"; then
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [duplicated-branches])
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [restrict])
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [alloc-zero])
tmp_CFLAGS="$tmp_CFLAGS -Wformat-overflow=2"
tmp_CFLAGS="$tmp_CFLAGS -Wformat-truncation=1" # =2 causes false positives
fi
#
dnl Only gcc 10 or later
if test "$compiler_num" -ge "1000"; then
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [arith-conversion])
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [enum-conversion])
fi
for flag in $CPPFLAGS; do
case "$flag" in
-I*)
dnl Include path, provide a -isystem option for the same dir
dnl to prevent warnings in those dirs. The -isystem was not very
dnl reliable on earlier gcc versions.
add=`echo $flag | sed 's/^-I/-isystem /g'`
tmp_CFLAGS="$tmp_CFLAGS $add"
;;
esac
done
fi dnl $ICC = no
CFLAGS="$CFLAGS $tmp_CFLAGS"
AC_MSG_NOTICE([Added this set of compiler options: $tmp_CFLAGS])
else dnl $GCC = yes
AC_MSG_NOTICE([Added no extra compiler options])
fi dnl $GCC = yes
dnl strip off optimizer flags
NEWFLAGS=""
for flag in $CFLAGS; do
case "$flag" in
-O*)
dnl echo "cut off $flag"
;;
*)
NEWFLAGS="$NEWFLAGS $flag"
;;
esac
done
CFLAGS=$NEWFLAGS
]) dnl end of AC_DEFUN() ]) dnl end of AC_DEFUN()