Browse Source

build: Check the availability of -Wpositive variant instead of -Wno-positive

At least gcc and clang do not warn on -Wno-* warning flags, only when
something else needs to be reported, which defeats our test. In those
cases pass an additional argument that will be what we will actually
check, but not use afterwards.
Guillem Jover 7 years ago
parent
commit
d72b33214a
2 changed files with 11 additions and 4 deletions
  1. 3 0
      debian/changelog
  2. 8 4
      m4/dpkg-compiler.m4

+ 3 - 0
debian/changelog

@@ -12,6 +12,9 @@ dpkg (1.18.11) UNRELEASED; urgency=medium
       mode (not used in Debian). Regression introduced in dpkg 1.18.8.
     - Change --with-* option logic to default to check.
     - Disable -Wtautological-constant-out-of-range-compare (for clang).
+    - Check the availability of -W<warning> variant instead of -Wno-<warning>.
+      As at least gcc and clang do not warn on -Wno-* warning flags, only
+      when some unrelated warning needs to be emitted.
 
   [ Updated manpages translations ]
   * German (Helge Kreutzmann).

+ 8 - 4
m4/dpkg-compiler.m4

@@ -4,6 +4,8 @@
 # DPKG_CHECK_COMPILER_FLAG
 # ------------------------
 AC_DEFUN([DPKG_CHECK_COMPILER_FLAG], [
+  m4_define([dpkg_check_flag], [m4_default([$2], [$1])])
+
   AC_LANG_CASE(
   [C], [
     m4_define([dpkg_compiler], [$CC])
@@ -21,7 +23,7 @@ AC_DEFUN([DPKG_CHECK_COMPILER_FLAG], [
   ])
   AC_CACHE_CHECK([whether ]dpkg_compiler[ accepts $1], [dpkg_varname_cache], [
     AS_VAR_COPY([dpkg_varname_save], [dpkg_varname])
-    AS_VAR_SET([dpkg_varname], ["$1 -Werror"])
+    AS_VAR_SET([dpkg_varname], ["-Werror dpkg_check_flag"])
     AC_COMPILE_IFELSE([
       AC_LANG_SOURCE([[]])
     ], [
@@ -43,9 +45,11 @@ AC_DEFUN([DPKG_CHECK_COMPILER_FLAG], [
 AC_DEFUN([DPKG_CHECK_COMPILER_WARNINGS], [
   DPKG_CHECK_COMPILER_FLAG([-Wall])
   DPKG_CHECK_COMPILER_FLAG([-Wextra])
-  DPKG_CHECK_COMPILER_FLAG([-Wno-unused-parameter])
-  DPKG_CHECK_COMPILER_FLAG([-Wno-missing-field-initializers])
-  DPKG_CHECK_COMPILER_FLAG([-Wno-tautological-constant-out-of-range-compare])
+  DPKG_CHECK_COMPILER_FLAG([-Wno-unused-parameter], [-Wunused-parameter])
+  DPKG_CHECK_COMPILER_FLAG([-Wno-missing-field-initializers],
+                           [-Wmissing-field-initializers])
+  DPKG_CHECK_COMPILER_FLAG([-Wno-tautological-constant-out-of-range-compare],
+                           [-Wtautological-constant-out-of-range-compare])
   DPKG_CHECK_COMPILER_FLAG([-Wmissing-declarations])
   DPKG_CHECK_COMPILER_FLAG([-Wmissing-format-attribute])
   DPKG_CHECK_COMPILER_FLAG([-Wformat -Wformat-security])