]> git.ipfire.org Git - thirdparty/automake.git/commitdiff
Warnings win over strictness on command line.
authorStefano Lattarini <stefano.lattarini@gmail.com>
Mon, 20 Dec 2010 11:10:56 +0000 (12:10 +0100)
committerStefano Lattarini <stefano.lattarini@gmail.com>
Sat, 15 Jan 2011 14:25:07 +0000 (15:25 +0100)
This change ensures that, on the command line at least, explicitly
defined warnings always take precedence over implicit strictness
implied warnings.  Related to Automake bug#7669 a.k.a. PR/547.

* automake.in (parse_arguments): Parse warnings only after the
strictness level has been processed.
* tests/gnuwarn.test: Update, plus miscellaneous improvements.
* tests/warnings-win-over-strictness.test: New test.
* tests/Makefile.am (TESTS): Update.

ChangeLog
automake.in
tests/Makefile.am
tests/Makefile.in
tests/gnuwarn.test
tests/warnings-win-over-strictness.test [new file with mode: 0755]

index 9130140af311d1886cb2ad95eecc8976a794f51f..0db84ff3cd0256d73b8fc96f28cdfef84eb1e22f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,16 @@
 2011-01-15  Stefano Lattarini  <stefano.lattarini@gmail.com>
 
+       For PR automake/547:
+       Warnings win over strictness on command line.
+       Ensure that, on the command line at least, explicitly defined
+       warnings always take precedence over implicit strictness-implied
+       warnings.  Related to Automake bug#7669 a.k.a. PR/547.
+       * automake.in (parse_arguments): Parse warnings only after the
+       strictness level has been processed.
+       * tests/gnuwarn.test: Update, plus miscellaneous improvements.
+       * tests/warnings-win-over-strictness.test: New test.
+       * tests/Makefile.am (TESTS): Update.
+
        More tests on warnings and strictness.
        * tests/warnings-strictness-interactions.test: New test.
        * tests/warnings-unknown.test: Likewise.
index 1d4601b1f11e491782c64db71fbe061fb20c77ed..e80a7361bc02b651af5e3ce8664207ff4bc8aa99 100644 (file)
@@ -8467,26 +8467,26 @@ EOF
 # Parse command line.
 sub parse_arguments ()
 {
-  # Start off as gnu.
-  set_strictness ('gnu');
+  my $strict = 'gnu';
+  my $cygnus = 0;
+  my $ignore_deps = 0;
+  my @warnings = ();
 
-  my $cli_where = new Automake::Location;
   my %cli_options =
     (
      'libdir=s'        => \$libdir,
-     'gnu'             => sub { set_strictness ('gnu'); },
-     'gnits'           => sub { set_strictness ('gnits'); },
-     'cygnus'          => sub { set_global_option ('cygnus', $cli_where); },
-     'foreign'          => sub { set_strictness ('foreign'); },
-     'include-deps'    => sub { unset_global_option ('no-dependencies'); },
-     'i|ignore-deps'   => sub { set_global_option ('no-dependencies',
-                                                   $cli_where); },
+     'gnu'             => sub { $strict = 'gnu'; },
+     'gnits'           => sub { $strict = 'gnits'; },
+     'foreign'         => sub { $strict = 'foreign'; },
+     'cygnus'          => \$cygnus,
+     'include-deps'    => sub { $ignore_deps = 0; },
+     'i|ignore-deps'   => sub { $ignore_deps = 1; },
      'no-force'        => sub { $force_generation = 0; },
      'f|force-missing'  => \$force_missing,
      'a|add-missing'   => \$add_missing,
      'c|copy'          => \$copy_missing,
      'v|verbose'       => sub { setup_channel 'verb', silent => 0; },
-     'W|warnings=s'     => \&parse_warnings,
+     'W|warnings=s'     => \@warnings,
      );
   use Getopt::Long;
   Getopt::Long::config ("bundling", "pass_through");
@@ -8515,6 +8515,15 @@ sub parse_arguments ()
   Getopt::Long::GetOptions %cli_options, 'version' => sub {}, 'help' => sub {}
     or exit 1;
 
+  set_strictness ($strict);
+  my $cli_where = new Automake::Location;
+  set_global_option ('cygnus', $cli_where) if $cygnus;
+  set_global_option ('no-dependencies', $cli_where) if $ignore_deps;
+  for my $warning (@warnings)
+    {
+      &parse_warnings ('-W', $warning);
+    }
+
   return unless @ARGV;
 
   if ($ARGV[0] =~ /^-./)
index 972f8a9bcb4d62195af50de3ac753fd54d75bd70..0523add3f14613747fbe9b14dffb9467849da54d 100644 (file)
@@ -950,6 +950,7 @@ warnings-precedence.test \
 warnings-strictness-interactions.test \
 warnings-unknown.test \
 warnopts.test \
+warnings-win-over-strictness.test \
 werror.test \
 werror2.test \
 werror3.test \
index 282afe0703d40941b861b250acd7d15129164239..72fdeec07da15488fe6897c7ee15af33b32cbcb0 100644 (file)
@@ -1213,6 +1213,7 @@ warnings-precedence.test \
 warnings-strictness-interactions.test \
 warnings-unknown.test \
 warnopts.test \
+warnings-win-over-strictness.test \
 werror.test \
 werror2.test \
 werror3.test \
index 43987b97ea8c9a276603fc73fc807428d26aecd0..3db7e857c0d261ff489fff646f9a1fce355ca891 100755 (executable)
@@ -18,6 +18,9 @@
 
 . ./defs || Exit 1
 
+# We need (almost) complete control over automake options.
+AUTOMAKE="$original_AUTOMAKE -Werror"
+
 cat >> configure.in << 'END'
 AC_PROG_CC
 AC_OUTPUT
@@ -38,12 +41,14 @@ END
 
 $ACLOCAL
 # Don't warn in foreign mode
-$AUTOMAKE -Wnone --add-missing --foreign
+$AUTOMAKE --add-missing --foreign
 # Warn in gnu mode
-AUTOMAKE_fails -Wnone --add-missing --gnu
-grep 'Makefile.am:1:.*CFLAGS' stderr
-grep 'Makefile.am:2:.*LDFLAGS' stderr
+AUTOMAKE_fails --add-missing --gnu
+grep '^Makefile\.am:1:.*CFLAGS' stderr
+grep '^Makefile\.am:2:.*LDFLAGS' stderr
 # No reason to warn about CXXFLAGS since it's not used.
 grep CXXFLAGS stderr && Exit 1
 # Don't warn if -Wno-gnu.
-$AUTOMAKE -Wnone --gnu -Wno-gnu
+$AUTOMAKE --gnu -Wno-gnu
+
+:
diff --git a/tests/warnings-win-over-strictness.test b/tests/warnings-win-over-strictness.test
new file mode 100755 (executable)
index 0000000..27936ec
--- /dev/null
@@ -0,0 +1,52 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Check that, on the command line, explicitly-defined warnings take
+# precedence over implicit strictness-implied warnings.
+
+. ./defs || Exit 1
+
+# We want complete control over automake options.
+AUTOMAKE=$original_AUTOMAKE
+
+ok ()
+{
+  AUTOMAKE_run 0 $*
+  test ! -s stderr
+}
+
+ko ()
+{
+  AUTOMAKE_run 0 $*
+  grep '^Makefile\.am:.*:=.*not portable' stderr
+  test `wc -l <stderr` -eq 1
+}
+
+# Files required in gnu strictness.
+touch README INSTALL NEWS AUTHORS ChangeLog COPYING
+
+cat > Makefile.am <<END
+FOO := bar
+END
+
+$ACLOCAL
+
+ko --foreign -Wportability
+ko -Wportability --foreign
+ok --gnu -Wno-portability
+ok -Wno-portability --gnu
+
+: