aboutsummaryrefslogtreecommitdiff
path: root/m4/curl-compilers.m4
diff options
context:
space:
mode:
Diffstat (limited to 'm4/curl-compilers.m4')
-rw-r--r--m4/curl-compilers.m4159
1 files changed, 98 insertions, 61 deletions
diff --git a/m4/curl-compilers.m4 b/m4/curl-compilers.m4
index c64db4bc6..7d59f0667 100644
--- a/m4/curl-compilers.m4
+++ b/m4/curl-compilers.m4
@@ -5,7 +5,7 @@
# | (__| |_| | _ <| |___
# \___|\___/|_| \_\_____|
#
-# Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
+# Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
#
# This software is licensed as described in the file COPYING, which
# you should have received as part of this distribution. The terms
@@ -151,8 +151,17 @@ AC_DEFUN([CURL_CHECK_COMPILER_DEC_C], [
dnl CURL_CHECK_COMPILER_GNU_C
dnl -------------------------------------------------
-dnl Verify if compiler being used is GNU C.
-
+dnl Verify if compiler being used is GNU C
+dnl
+dnl $compiler_num will be set to MAJOR * 100 + MINOR for gcc less than version
+dnl 7 and just $MAJOR * 100 for gcc version 7 and later.
+dnl
+dnl Examples:
+dnl Version 1.2.3 => 102
+dnl Version 2.95 => 295
+dnl Version 4.7 => 407
+dnl Version 9.2.1 => 900
+dnl
AC_DEFUN([CURL_CHECK_COMPILER_GNU_C], [
AC_REQUIRE([CURL_CHECK_COMPILER_INTEL_C])dnl
AC_REQUIRE([CURL_CHECK_COMPILER_CLANG])dnl
@@ -443,8 +452,10 @@ dnl GNUC versions these warnings are not silenced.
AC_DEFUN([CURL_CONVERT_INCLUDE_TO_ISYSTEM], [
AC_REQUIRE([CURL_SHFUNC_SQUEEZE])dnl
AC_REQUIRE([CURL_CHECK_COMPILER])dnl
+ AC_MSG_CHECKING([convert -I options to -isystem])
if test "$compiler_id" = "GNU_C" ||
test "$compiler_id" = "CLANG"; then
+ AC_MSG_RESULT([yes])
tmp_has_include="no"
tmp_chg_FLAGS="$CFLAGS"
for word1 in $tmp_chg_FLAGS; do
@@ -475,6 +486,8 @@ AC_DEFUN([CURL_CONVERT_INCLUDE_TO_ISYSTEM], [
CPPFLAGS="$tmp_chg_FLAGS"
squeeze CPPFLAGS
fi
+ else
+ AC_MSG_RESULT([no])
fi
])
@@ -561,11 +574,6 @@ AC_DEFUN([CURL_SET_COMPILER_BASIC_OPTS], [
#
if test "$compiler_id" != "unknown"; then
#
- if test "$compiler_id" = "GNU_C" ||
- test "$compiler_id" = "CLANG"; then
- CURL_CONVERT_INCLUDE_TO_ISYSTEM
- fi
- #
tmp_save_CPPFLAGS="$CPPFLAGS"
tmp_save_CFLAGS="$CFLAGS"
tmp_CPPFLAGS=""
@@ -878,36 +886,36 @@ AC_DEFUN([CURL_SET_COMPILER_WARNING_OPTS], [
#
if test "$want_warnings" = "yes"; then
tmp_CFLAGS="$tmp_CFLAGS -pedantic"
- tmp_CFLAGS="$tmp_CFLAGS -Wall -Wextra"
- tmp_CFLAGS="$tmp_CFLAGS -Wpointer-arith -Wwrite-strings"
- tmp_CFLAGS="$tmp_CFLAGS -Wshadow"
- tmp_CFLAGS="$tmp_CFLAGS -Winline -Wnested-externs"
- tmp_CFLAGS="$tmp_CFLAGS -Wmissing-declarations"
- tmp_CFLAGS="$tmp_CFLAGS -Wmissing-prototypes"
+ 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])
+ 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])
tmp_CFLAGS="$tmp_CFLAGS -Wno-long-long"
- tmp_CFLAGS="$tmp_CFLAGS -Wfloat-equal"
- tmp_CFLAGS="$tmp_CFLAGS -Wno-multichar -Wsign-compare"
- tmp_CFLAGS="$tmp_CFLAGS -Wundef"
+ CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [float-equal])
+ CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [no-multichar sign-compare])
+ CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [undef])
tmp_CFLAGS="$tmp_CFLAGS -Wno-format-nonliteral"
- tmp_CFLAGS="$tmp_CFLAGS -Wendif-labels -Wstrict-prototypes"
- tmp_CFLAGS="$tmp_CFLAGS -Wdeclaration-after-statement"
- tmp_CFLAGS="$tmp_CFLAGS -Wcast-align"
+ CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [endif-labels strict-prototypes])
+ CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [declaration-after-statement])
+ CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [cast-align])
tmp_CFLAGS="$tmp_CFLAGS -Wno-system-headers"
- tmp_CFLAGS="$tmp_CFLAGS -Wshorten-64-to-32"
+ CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [shorten-64-to-32])
#
dnl Only clang 1.1 or later
if test "$compiler_num" -ge "101"; then
- tmp_CFLAGS="$tmp_CFLAGS -Wunused"
+ CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [unused])
fi
#
dnl Only clang 2.8 or later
if test "$compiler_num" -ge "208"; then
- tmp_CFLAGS="$tmp_CFLAGS -Wvla"
+ 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 -Wshift-sign-overflow"
+ CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [shift-sign-overflow])
fi
#
dnl Only clang 3.2 or later
@@ -918,25 +926,29 @@ AC_DEFUN([CURL_SET_COMPILER_WARNING_OPTS], [
dnl mingw because the libtool wrapper executable causes them
;;
*)
- tmp_CFLAGS="$tmp_CFLAGS -Wmissing-variable-declarations"
+ CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [missing-variable-declarations])
;;
esac
fi
#
dnl Only clang 3.6 or later
if test "$compiler_num" -ge "306"; then
- tmp_CFLAGS="$tmp_CFLAGS -Wdouble-promotion"
+ CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [double-promotion])
fi
#
dnl Only clang 3.9 or later
if test "$compiler_num" -ge "309"; then
- tmp_CFLAGS="$tmp_CFLAGS -Wcomma"
+ 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])
+ fi
fi
;;
#
@@ -960,43 +972,45 @@ AC_DEFUN([CURL_SET_COMPILER_WARNING_OPTS], [
fi
#
dnl Set of options we believe *ALL* gcc versions support:
- tmp_CFLAGS="$tmp_CFLAGS -Wall -W"
+ CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [all])
+ tmp_CFLAGS="$tmp_CFLAGS -W"
#
dnl Only gcc 1.4 or later
if test "$compiler_num" -ge "104"; then
- tmp_CFLAGS="$tmp_CFLAGS -Wpointer-arith -Wwrite-strings"
+ CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [pointer-arith write-strings])
dnl If not cross-compiling with a gcc older than 3.0
if test "x$cross_compiling" != "xyes" ||
test "$compiler_num" -ge "300"; then
- tmp_CFLAGS="$tmp_CFLAGS -Wunused -Wshadow"
+ CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [unused shadow])
fi
fi
#
dnl Only gcc 2.7 or later
if test "$compiler_num" -ge "207"; then
- tmp_CFLAGS="$tmp_CFLAGS -Winline -Wnested-externs"
+ CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [inline nested-externs])
dnl If not cross-compiling with a gcc older than 3.0
if test "x$cross_compiling" != "xyes" ||
test "$compiler_num" -ge "300"; then
- tmp_CFLAGS="$tmp_CFLAGS -Wmissing-declarations"
- tmp_CFLAGS="$tmp_CFLAGS -Wmissing-prototypes"
+ CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [missing-declarations])
+ CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [missing-prototypes])
fi
fi
#
dnl Only gcc 2.95 or later
if test "$compiler_num" -ge "295"; then
tmp_CFLAGS="$tmp_CFLAGS -Wno-long-long"
- tmp_CFLAGS="$tmp_CFLAGS -Wbad-function-cast"
+ CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [bad-function-cast])
fi
#
dnl Only gcc 2.96 or later
if test "$compiler_num" -ge "296"; then
- tmp_CFLAGS="$tmp_CFLAGS -Wfloat-equal"
- tmp_CFLAGS="$tmp_CFLAGS -Wno-multichar -Wsign-compare"
+ CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [float-equal])
+ tmp_CFLAGS="$tmp_CFLAGS -Wno-multichar"
+ CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [sign-compare])
dnl -Wundef used only if gcc is 2.96 or later since we get
dnl lots of "`_POSIX_C_SOURCE' is not defined" in system
dnl headers with gcc 2.95.4 on FreeBSD 4.9
- tmp_CFLAGS="$tmp_CFLAGS -Wundef"
+ CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [undef])
fi
#
dnl Only gcc 2.97 or later
@@ -1015,13 +1029,13 @@ AC_DEFUN([CURL_SET_COMPILER_WARNING_OPTS], [
#
dnl Only gcc 3.3 or later
if test "$compiler_num" -ge "303"; then
- tmp_CFLAGS="$tmp_CFLAGS -Wendif-labels -Wstrict-prototypes"
+ CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [endif-labels strict-prototypes])
fi
#
dnl Only gcc 3.4 or later
if test "$compiler_num" -ge "304"; then
- tmp_CFLAGS="$tmp_CFLAGS -Wdeclaration-after-statement"
- tmp_CFLAGS="$tmp_CFLAGS -Wold-style-definition"
+ 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
@@ -1031,15 +1045,17 @@ AC_DEFUN([CURL_SET_COMPILER_WARNING_OPTS], [
#
dnl Only gcc 4.2 or later
if test "$compiler_num" -ge "402"; then
- tmp_CFLAGS="$tmp_CFLAGS -Wcast-align"
+ CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [cast-align])
fi
#
dnl Only gcc 4.3 or later
if test "$compiler_num" -ge "403"; then
- tmp_CFLAGS="$tmp_CFLAGS -Wtype-limits -Wold-style-declaration"
- tmp_CFLAGS="$tmp_CFLAGS -Wmissing-parameter-type -Wempty-body"
- tmp_CFLAGS="$tmp_CFLAGS -Wclobbered -Wignored-qualifiers"
- tmp_CFLAGS="$tmp_CFLAGS -Wconversion -Wno-sign-conversion -Wvla"
+ 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
@@ -1054,7 +1070,7 @@ AC_DEFUN([CURL_SET_COMPILER_WARNING_OPTS], [
#
dnl Only gcc 4.6 or later
if test "$compiler_num" -ge "406"; then
- tmp_CFLAGS="$tmp_CFLAGS -Wdouble-promotion"
+ CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [double-promotion])
fi
#
dnl only gcc 4.8 or later
@@ -1069,18 +1085,19 @@ AC_DEFUN([CURL_SET_COMPILER_WARNING_OPTS], [
#
dnl Only gcc 6 or later
if test "$compiler_num" -ge "600"; then
- tmp_CFLAGS="$tmp_CFLAGS -Wshift-negative-value"
+ CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [shift-negative-value])
tmp_CFLAGS="$tmp_CFLAGS -Wshift-overflow=2"
- tmp_CFLAGS="$tmp_CFLAGS -Wnull-dereference -fdelete-null-pointer-checks"
- tmp_CFLAGS="$tmp_CFLAGS -Wduplicated-cond"
- tmp_CFLAGS="$tmp_CFLAGS -Wunused-const-variable"
+ 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
- tmp_CFLAGS="$tmp_CFLAGS -Wduplicated-branches"
- tmp_CFLAGS="$tmp_CFLAGS -Wrestrict"
- tmp_CFLAGS="$tmp_CFLAGS -Walloc-zero"
+ 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=2"
tmp_CFLAGS="$tmp_CFLAGS -Wimplicit-fallthrough=4"
@@ -1106,6 +1123,10 @@ AC_DEFUN([CURL_SET_COMPILER_WARNING_OPTS], [
fi
fi
fi
+ dnl Only gcc 10 or later
+ if test "$compiler_num" -ge "1000"; then
+ CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [enum-conversion])
+ fi
;;
#
HP_UX_C)
@@ -1156,11 +1177,6 @@ AC_DEFUN([CURL_SET_COMPILER_WARNING_OPTS], [
tmp_CFLAGS="$tmp_CFLAGS -fno-strict-aliasing"
dnl Value-safe optimizations on floating-point data
tmp_CFLAGS="$tmp_CFLAGS -fp-model precise"
- dnl Only icc 10.0 or later
- if test "$compiler_num" -ge "1000"; then
- dnl Disable vectorizer diagnostic information
- tmp_CFLAGS="$tmp_CFLAGS -vec-report0"
- fi
;;
#
INTEL_WINDOWS_C)
@@ -1211,11 +1227,11 @@ AC_DEFUN([CURL_SET_COMPILER_WARNING_OPTS], [
#
if test "$want_warnings" = "yes"; then
dnl Activate all warnings
- tmp_CFLAGS="$tmp_CFLAGS -Wall"
+ CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [all])
dnl Make string constants be of type const char *
- tmp_CFLAGS="$tmp_CFLAGS -Wwrite-strings"
+ CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [write-strings])
dnl Warn use of unsupported GCC features ignored by TCC
- tmp_CFLAGS="$tmp_CFLAGS -Wunsupported"
+ CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [unsupported])
fi
;;
#
@@ -1642,3 +1658,24 @@ AC_DEFUN([CURL_VAR_STRIP], [
[$1]="$ac_var_stripped"
squeeze [$1]
])
+
+dnl CURL_ADD_COMPILER_WARNINGS (WARNING-LIST, NEW-WARNINGS)
+dnl -------------------------------------------------------
+dnl Contents of variable WARNING-LIST and NEW-WARNINGS are
+dnl handled as whitespace separated lists of words.
+dnl Add each compiler warning from NEW-WARNINGS that has not
+dnl been disabled via CFLAGS to WARNING-LIST.
+
+AC_DEFUN([CURL_ADD_COMPILER_WARNINGS], [
+ AC_REQUIRE([CURL_SHFUNC_SQUEEZE])dnl
+ ac_var_added_warnings=""
+ for warning in [$2]; do
+ CURL_VAR_MATCH(CFLAGS, [-Wno-$warning -W$warning])
+ if test "$ac_var_match_word" = "no"; then
+ ac_var_added_warnings="$ac_var_added_warnings -W$warning"
+ fi
+ done
+ dnl squeeze whitespace out of result
+ [$1]="$[$1] $ac_var_added_warnings"
+ squeeze [$1]
+])