warnings: 'extra-portability' category is not implied by '-Wall'
authorStefano Lattarini <stefano.lattarini@gmail.com>
Fri, 4 Nov 2011 10:26:51 +0000 (11:26 +0100)
committerStefano Lattarini <stefano.lattarini@gmail.com>
Fri, 4 Nov 2011 10:35:19 +0000 (11:35 +0100)
This change is only intended for the 1.11.x series.  In automake
1.12, `-Wall' will be meant to enable `-Wextra-portability'.

* lib/Automake/ChannelDefs.pm (switch_warning): Do not enable
extra-portability warnings when `-Wall' is given.  Use ...
($have_extra_portability ): ... this new global variable.
Add a trailing "1;" to avoid spurious errors upon the importing
of this module.
* tests/extra-portability.test: Update and extend.
* NEWS: Update.

ChangeLog
NEWS
lib/Automake/ChannelDefs.pm
tests/extra-portability.test

index d8133c9..b43e29d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2011-11-04  Stefano Lattarini  <stefano.lattarini@gmail.com>
+
+       warnings: 'extra-portability' category is not implied by '-Wall'
+       This change is only intended for the 1.11.x series.  In automake
+       1.12, `-Wall' will be meant to enable `-Wextra-portability'.
+       * lib/Automake/ChannelDefs.pm (switch_warning): Do not enable
+       extra-portability warnings when `-Wall' is given.  Use ...
+       ($have_extra_portability ): ... this new global variable.
+       Add a trailing "1;" to avoid spurious errors upon the importing
+       of this module.
+       * tests/extra-portability.test: Update and extend.
+       * NEWS: Update.
+
 2011-11-03  Stefano Lattarini  <stefano.lattarini@gmail.com>
 
        tests: various minor tweakings, mostly related to AM_PROG_AR
diff --git a/NEWS b/NEWS
index f648e6f..8f47b19 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -12,6 +12,10 @@ New in 1.11.1a:
     search path are looked up is probably going to be changed in the
     next Automake release (1.12).
 
+  - Starting from the next Automake release (1.12), warnings in the
+    `extra-portability' category will be enabled by `-Wall' (right now,
+    one has to use `-Wextra-portability' explicitly).
+
 * Changes to aclocal:
 
   - The `--acdir' option is deprecated.  Now you should use the new options
@@ -46,7 +50,7 @@ New in 1.11.1a:
   - New macro AM_PROG_AR that looks for an archiver and wraps it in the new
     'ar-lib' auxiliary script if the found archiver is Microsoft lib.  This
     new macro is required for LIBRARIES and LTLIBRARIES when automake is
-    run with -Wextra-portability (or -Wall) and -Werror.
+    run with -Wextra-portability and -Werror.
 
   - When using DejaGnu-based testsuites, the user can extend the `site.exp'
     file generated by automake-provided rules by defining the special make
index 61b4ed4..8dff186 100644 (file)
@@ -258,6 +258,10 @@ Else handle C<all> and C<none> for completeness.
 
 =cut
 
+# HACK to have `-Wextra-portability' *not* implied by `-Wall'.
+# This will go away in automake 1.12.
+my $have_extra_portability = 0;
+
 sub switch_warning ($)
 {
   my ($cat) = @_;
@@ -272,6 +276,8 @@ sub switch_warning ($)
   if ($cat eq 'all')
     {
       setup_channel_type 'warning', silent => $has_no;
+      setup_channel 'extra-portability', silent => 1
+        unless $have_extra_portability;
     }
   elsif ($cat eq 'none')
     {
@@ -290,10 +296,16 @@ sub switch_warning ($)
       setup_channel $cat, silent => $has_no;
       setup_channel 'portability-recursive', silent => $has_no
         if $cat eq 'portability';
-      setup_channel 'extra-portability', silent => $has_no
-        if ($cat eq 'portability' && $has_no);
-      setup_channel 'portability', silent => $has_no
-        if ($cat eq 'extra-portability' && ! $has_no);
+      if ($cat eq 'portability' && $has_no)
+        {
+          setup_channel 'extra-portability', silent => 1;
+          $have_extra_portability = 0;
+        }
+      if ($cat eq 'extra-portability' && ! $has_no)
+        {
+          setup_channel 'portability', silent => 0;
+          $have_extra_portability = 1;
+        }
     }
   else
     {
@@ -382,6 +394,8 @@ sub set_strictness ($)
     }
 }
 
+1;
+
 =back
 
 =head1 SEE ALSO
index 191dcb4..ce833b4 100755 (executable)
@@ -18,6 +18,7 @@
 # warning categories:
 #   1. `-Wextra-portability' must imply `-Wportability'.
 #   2. `-Wno-portability' must imply `-Wno-extra-portability'.
+#   3. `-Wall' does *not* imply `-Wextra-portability'.
 
 . ./defs || Exit 1
 
@@ -32,11 +33,22 @@ END
 cat >Makefile.am <<END
 EXTRA_LIBRARIES = libfoo.a
 libfoo_a_SOURCES = sub/foo.c
-libfoo_a_CPPFLAGS = -Dwhatever
 END
 
 $ACLOCAL
 
+# `-Wall' does not enable extra-portability warnings.
+$AUTOMAKE -Wall -Werror
+
+# Enabling extra-portability works.
+AUTOMAKE_fails -Wnone -Wextra-portability
+grep 'requires.*AM_PROG_AR' stderr
+# Disabling portability disables extra-portability.
+$AUTOMAKE -Wno-portability -Wall
+$AUTOMAKE -Wextra-portability -Wno-portability -Wall
+
+echo libfoo_a_CPPFLAGS = -Dwhatever >> Makefile.am
+
 # Enabling extra-portability enables portability.
 AUTOMAKE_fails -Wnone -Wextra-portability
 # The expected diagnostic is
@@ -47,6 +59,12 @@ AUTOMAKE_fails -Wnone -Wextra-portability
 grep 'requires.*AM_PROG_CC_C_O' stderr
 grep 'requires.*AM_PROG_AR' stderr
 
+# `-Wall' does not reset extra portability warnings to their
+# default (i.e., disabled).
+AUTOMAKE_fails -Wextra-portability -Wall
+grep 'requires.*AM_PROG_CC_C_O' stderr
+grep 'requires.*AM_PROG_AR' stderr
+
 # Disabling extra-portability leaves portability intact.
 AUTOMAKE_fails -Wno-extra-portability
 # The expected diagnostic is
@@ -55,6 +73,12 @@ AUTOMAKE_fails -Wno-extra-portability
 grep 'requires.*AM_PROG_CC_C_O' stderr
 grep 'requires.*AM_PROG_AR' stderr && Exit 1
 
+# `-Wall' does not set extra portability warnings if they have
+# been previously disabled.
+AUTOMAKE_fails -Wno-extra-portability -Wall
+grep 'requires.*AM_PROG_CC_C_O' stderr
+grep 'requires.*AM_PROG_AR' stderr && Exit 1
+
 # Enabling portability does not enable extra-portability.
 AUTOMAKE_fails -Wnone -Wportability
 # The expected diagnostic is
@@ -65,5 +89,6 @@ grep 'requires.*AM_PROG_AR' stderr && Exit 1
 
 # Disabling portability disables extra-portability.
 $AUTOMAKE -Wno-portability
+$AUTOMAKE -Wextra-portability -Wno-portability
 
 :