]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
Set autoconf's default warnings to `syntax'.
authorAkim Demaille <akim@epita.fr>
Mon, 10 Jul 2000 10:23:08 +0000 (10:23 +0000)
committerAkim Demaille <akim@epita.fr>
Mon, 10 Jul 2000 10:23:08 +0000 (10:23 +0000)
In fact, honor the most recent specification in the concatenation
of `syntax',$WARNINGS,<options> in that order.
Implement support for `none' and `noCATEGORY' so that the options
may override the previous choices.
Suggested by Didier Verna.

* acgeneral.m4 (_AC_WARNING_IFELSE): New macro.
(AC_WARNING_IFELSE): Use this macro to implement the new specs.
(AC_WARNING): The empty category must not be used, default to
`syntax'.
* doc/autoconf.texi (autoconf Invocation, Reporting Messages): Adjust.
* autoconf.sh: Adjust.
Use `optarg' to fetch the arguments of options.
Fix a bug in the handling of `--trace='.

* acgeneral.m4 (AC_CACHE_VAL): Typo: the macro was complaining iff
it shouldn't have.

ChangeLog
acgeneral.m4
autoconf.in
autoconf.sh
bin/autoconf.in
doc/autoconf.texi
lib/autoconf/general.m4

index 59086cb8dbbd1db0c8edb4ea5f0175a995177b24..8969e18daaad1d6b453643c7c0e0ceaf94037239 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,25 @@
+2000-07-10  Akim Demaille  <akim@epita.fr>
+
+       Set autoconf's default warnings to `syntax'.
+
+       In fact, honor the most recent specification in the concatenation
+       of `syntax',$WARNINGS,<options> in that order.
+       Implement support for `none' and `noCATEGORY' so that the options
+       may override the previous choices.
+       Suggested by Didier Verna.
+
+       * acgeneral.m4 (_AC_WARNING_IFELSE): New macro.
+       (AC_WARNING_IFELSE): Use this macro to implement the new specs.
+       (AC_WARNING): The empty category must not be used, default to
+       `syntax'.
+       * doc/autoconf.texi (autoconf Invocation, Reporting Messages): Adjust.
+       * autoconf.sh: Adjust.
+       Use `optarg' to fetch the arguments of options.
+       Fix a bug in the handling of `--trace='.
+
+       * acgeneral.m4 (AC_CACHE_VAL): Typo: the macro was complaining iff
+       it shouldn't have.
+
 2000-07-10  Akim Demaille  <akim@epita.fr>
 
        * autoreconf.sh (--install, --symlink): New options.
index a8373299afc91f54b837ea2615ef61b648ffcce2..d88d34f18cfd83328c1756cd98ff9a5a1118eefe 100644 (file)
@@ -2393,7 +2393,7 @@ rm -f confcache[]dnl
 # The name of shell var CACHE-ID must contain `_cv_' in order to get saved.
 # Should be dnl'ed.  Try to catch common mistakes.
 define([AC_CACHE_VAL],
-[ifelse(regexp([$2], [AC_DEFINE]), [-1],
+[ifelse(regexp([$2], [AC_DEFINE]), [-1], [],
                [AC_DIAGNOSE(syntax,
 [$0($1, ...): suspicious presence of an AC_DEFINE in the second argument, ]dnl
 [where no actions should be taken])])dnl
@@ -2500,9 +2500,29 @@ s,@$1@,,;t t])])
 # If the CATEGORY of warnings is enabled, expand IF_TRUE otherwise
 # IF-FALSE.  CATEGORY is enabled iff `AC_WARNING_ENABLE(CATEGORY)' or
 # `AC_WARNING_ENABLE(all)' is defined.
+#
+# The variable `_AC_WARNINGS' contains a comma separated list of
+# warnings which order is the converse from the one specified by
+# the user, i.e., if she specified `-W error,none,obsolete',
+# `_AC_WARNINGS' is `obsolete,none,error'.  We read it from left to
+# right, and:
+# - if none or noCATEGORY is met, run IF-FALSE
+# - if all or CATEGORY is met, run IF-TRUE
+# - if there is nothing left, run IF-FALSE.
 define([AC_WARNING_IFELSE],
-[ifdef([AC_WARNING_ENABLE($1)], [$2],
-       [ifdef([AC_WARNING_ENABLE(all)], [$2], [$3])])])
+[_AC_WARNING_IFELSE([$1], [$2], [$3], _AC_WARNINGS)])
+
+
+# _AC_WARNING_IFELSE(CATEGORY, IF-TRUE, IF-FALSE, WARNING1, ...)
+# --------------------------------------------------------------
+# Implementation of the loop described above.
+define([_AC_WARNING_IFELSE],
+[ifelse([$4],  [$1],   [$2],
+        [$4],  [all],  [$2],
+        [$4],  [],     [$3],
+        [$4],  [none], [$3],
+        [$4],  [no$1], [$3],
+        [$0([$1], [$2], [$3], m4_shiftn(4, $@))])])
 
 
 # _AC_DIAGNOSE(MESSAGE)
@@ -2527,7 +2547,7 @@ define([AC_DIAGNOSE],
 # -------------------
 # Report a MESSAGE to the user of autoconf if `-W' or `-W all' was
 # specified.
-define([AC_WARNING], [AC_DIAGNOSE([], [$1])])
+define([AC_WARNING], [AC_DIAGNOSE([syntax], [$1])])
 
 
 # AC_FATAL(MESSAGE, [EXIT-STATUS])
index 56caf60d3c81275b611137b9be01b16398225fd1..385a44fcfad81a64784185d232dcc952e54d7515 100644 (file)
@@ -38,14 +38,18 @@ Operation modes:
   -m, --macrodir=DIR       directory storing Autoconf's macro files
   -l, --localdir=DIR       directory storing the \`aclocal.m4' file
   -o, --output=FILE        save output in FILE (stdout is the default)
-  -W, --warnings=CATEGORY  report the warnings falling in CATEGORY
+  -W, --warnings=CATEGORY  report the warnings falling in CATEGORY [syntax]
 
 Warning categories include:
-  \`cross'      cross compilation issues
-  \`obsolete'   obsolete constructs
-  \`syntax'     dubious syntactic constructs
-  \`all'        all the warnings
-  \`error'      warnings are error
+  \`cross'        cross compilation issues
+  \`obsolete'     obsolete constructs
+  \`syntax'       dubious syntactic constructs
+  \`all'          all the warnings
+  \`noCATEGORY'   turn off the warnings on CATEGORY
+  \`none'         turn off all the warnings
+  \`error'        warnings are error
+
+The environment variable \`WARNINGS' is honored.
 
 Tracing:
   -t, --trace=MACRO     report the list of calls to MACRO
@@ -127,7 +131,9 @@ verbose=:
 
 # Parse command line.
 while test $# -gt 0 ; do
-  case "$1" in
+  optarg=`expr "$1" : '--[^=]*=\(.*\)' \| \
+               "$1" : '-.\(.*\)'`
+  case $1 in
     --version | --vers* | -V )
        echo "$version" ; exit 0 ;;
     --help | --h* | -h )
@@ -140,7 +146,7 @@ while test $# -gt 0 ; do
        shift;;
 
     --localdir=* | --l*=* )
-       localdir=`echo "$1" | sed -e 's/^[^=]*=//'`
+       localdir=$optarg
        shift ;;
     --localdir | --l* | -l )
        test $# = 1 && eval "$exit_missing_arg"
@@ -149,7 +155,7 @@ while test $# -gt 0 ; do
        shift ;;
 
     --macrodir=* | --m*=* )
-       AC_MACRODIR=`echo "$1" | sed -e 's/^[^=]*=//'`
+       AC_MACRODIR=$optarg
        shift ;;
     --macrodir | --m* | -m )
        test $# = 1 && eval "$exit_missing_arg"
@@ -169,8 +175,7 @@ while test $# -gt 0 ; do
        shift ;;
     --trace=* )
        task=trace
-       traces="$traces '"`echo "$1" |
-                          sed -e "s/^[^=]*=//;s/:.*//;s/'/'\\\\\\\\''/g"`"'"
+       traces="$traces '"`echo "$optarg" | sed "s/'/'\\\\\\\\''/g"`"'"
        shift ;;
     --initialization | -i )
        initialization=:
@@ -182,22 +187,22 @@ while test $# -gt 0 ; do
        outfile=$1
        shift ;;
     --output=* )
-       outfile=`echo "$1" | sed -e 's/^[^=]*=//'`
+       outfile=$optarg
        shift ;;
     -o* )
-       outfile=`expr "$1" : '-o\(.*\)'`
+       outfile=$optarg
        shift ;;
 
     --warnings | -W )
        test $# = 1 && eval "$exit_missing_arg"
        shift
-       warnings="$warnings "`echo $1 | sed -e 's/,/ /g'`
+       warnings=$warnings,$1
        shift ;;
     --warnings=* )
-       warnings="$warnings "`echo "$1" | sed -e 's/^[^=]*=//;s/,/ /g'`
+       warnings=$warnings,$optarg
        shift ;;
     -W* ) # People are used to -Wall, -Werror etc.
-       warnings="$warnings "`echo "$1" | sed -e 's/^-W//;s/,/ /g'`
+       warnings=$warnings,$optarg
        shift ;;
 
     -- )     # Stop option processing
@@ -214,8 +219,16 @@ while test $# -gt 0 ; do
   esac
 done
 
-# Support $WARNINGS.
-: ${warnings=`echo $WARNINGS | sed -e 's/,/ /g'`}
+# The warnings are the concatenation of 1. application's defaults,
+# 2. $WARNINGS, $3 command line options, in that order.
+# Set them in the order expected by the M4 macros: the converse.
+_ac_warnings=
+for warning in `IFS=,; echo syntax,$WARNINGS,$warnings | tr [A-Z] [a-z]`
+do
+  test -n $warning || continue
+  _ac_warnings="$warning"`test -n "$_ac_warnings" && echo ",$_ac_warnings"`
+done
+
 
 # Trap on 0 to stop playing with `rm'.
 $debug ||
@@ -283,10 +296,8 @@ case $task in
   ## Generate the `configure' script.  ##
   ## --------------------------------- ##
   script)
-  # Enable the requested warnings.
-  warnings_opt=`echo "$warnings" |
-                sed -e 's/\([^ ][^ ]*\)/-DAC_WARNING_ENABLE(\1) /g'`
-  $run_m4f $warnings_opt $infile >$tmp/configure || exit 2
+  # M4 expansion.
+  $run_m4f -D_AC_WARNINGS=$_ac_warnings $infile >$tmp/configure || exit 2
 
   # You could add your own prefixes to pattern if you wanted to check for
   # them too, e.g. pattern='\(AC_\|ILT_\)', except that UNIX sed doesn't do
index 56caf60d3c81275b611137b9be01b16398225fd1..385a44fcfad81a64784185d232dcc952e54d7515 100644 (file)
@@ -38,14 +38,18 @@ Operation modes:
   -m, --macrodir=DIR       directory storing Autoconf's macro files
   -l, --localdir=DIR       directory storing the \`aclocal.m4' file
   -o, --output=FILE        save output in FILE (stdout is the default)
-  -W, --warnings=CATEGORY  report the warnings falling in CATEGORY
+  -W, --warnings=CATEGORY  report the warnings falling in CATEGORY [syntax]
 
 Warning categories include:
-  \`cross'      cross compilation issues
-  \`obsolete'   obsolete constructs
-  \`syntax'     dubious syntactic constructs
-  \`all'        all the warnings
-  \`error'      warnings are error
+  \`cross'        cross compilation issues
+  \`obsolete'     obsolete constructs
+  \`syntax'       dubious syntactic constructs
+  \`all'          all the warnings
+  \`noCATEGORY'   turn off the warnings on CATEGORY
+  \`none'         turn off all the warnings
+  \`error'        warnings are error
+
+The environment variable \`WARNINGS' is honored.
 
 Tracing:
   -t, --trace=MACRO     report the list of calls to MACRO
@@ -127,7 +131,9 @@ verbose=:
 
 # Parse command line.
 while test $# -gt 0 ; do
-  case "$1" in
+  optarg=`expr "$1" : '--[^=]*=\(.*\)' \| \
+               "$1" : '-.\(.*\)'`
+  case $1 in
     --version | --vers* | -V )
        echo "$version" ; exit 0 ;;
     --help | --h* | -h )
@@ -140,7 +146,7 @@ while test $# -gt 0 ; do
        shift;;
 
     --localdir=* | --l*=* )
-       localdir=`echo "$1" | sed -e 's/^[^=]*=//'`
+       localdir=$optarg
        shift ;;
     --localdir | --l* | -l )
        test $# = 1 && eval "$exit_missing_arg"
@@ -149,7 +155,7 @@ while test $# -gt 0 ; do
        shift ;;
 
     --macrodir=* | --m*=* )
-       AC_MACRODIR=`echo "$1" | sed -e 's/^[^=]*=//'`
+       AC_MACRODIR=$optarg
        shift ;;
     --macrodir | --m* | -m )
        test $# = 1 && eval "$exit_missing_arg"
@@ -169,8 +175,7 @@ while test $# -gt 0 ; do
        shift ;;
     --trace=* )
        task=trace
-       traces="$traces '"`echo "$1" |
-                          sed -e "s/^[^=]*=//;s/:.*//;s/'/'\\\\\\\\''/g"`"'"
+       traces="$traces '"`echo "$optarg" | sed "s/'/'\\\\\\\\''/g"`"'"
        shift ;;
     --initialization | -i )
        initialization=:
@@ -182,22 +187,22 @@ while test $# -gt 0 ; do
        outfile=$1
        shift ;;
     --output=* )
-       outfile=`echo "$1" | sed -e 's/^[^=]*=//'`
+       outfile=$optarg
        shift ;;
     -o* )
-       outfile=`expr "$1" : '-o\(.*\)'`
+       outfile=$optarg
        shift ;;
 
     --warnings | -W )
        test $# = 1 && eval "$exit_missing_arg"
        shift
-       warnings="$warnings "`echo $1 | sed -e 's/,/ /g'`
+       warnings=$warnings,$1
        shift ;;
     --warnings=* )
-       warnings="$warnings "`echo "$1" | sed -e 's/^[^=]*=//;s/,/ /g'`
+       warnings=$warnings,$optarg
        shift ;;
     -W* ) # People are used to -Wall, -Werror etc.
-       warnings="$warnings "`echo "$1" | sed -e 's/^-W//;s/,/ /g'`
+       warnings=$warnings,$optarg
        shift ;;
 
     -- )     # Stop option processing
@@ -214,8 +219,16 @@ while test $# -gt 0 ; do
   esac
 done
 
-# Support $WARNINGS.
-: ${warnings=`echo $WARNINGS | sed -e 's/,/ /g'`}
+# The warnings are the concatenation of 1. application's defaults,
+# 2. $WARNINGS, $3 command line options, in that order.
+# Set them in the order expected by the M4 macros: the converse.
+_ac_warnings=
+for warning in `IFS=,; echo syntax,$WARNINGS,$warnings | tr [A-Z] [a-z]`
+do
+  test -n $warning || continue
+  _ac_warnings="$warning"`test -n "$_ac_warnings" && echo ",$_ac_warnings"`
+done
+
 
 # Trap on 0 to stop playing with `rm'.
 $debug ||
@@ -283,10 +296,8 @@ case $task in
   ## Generate the `configure' script.  ##
   ## --------------------------------- ##
   script)
-  # Enable the requested warnings.
-  warnings_opt=`echo "$warnings" |
-                sed -e 's/\([^ ][^ ]*\)/-DAC_WARNING_ENABLE(\1) /g'`
-  $run_m4f $warnings_opt $infile >$tmp/configure || exit 2
+  # M4 expansion.
+  $run_m4f -D_AC_WARNINGS=$_ac_warnings $infile >$tmp/configure || exit 2
 
   # You could add your own prefixes to pattern if you wanted to check for
   # them too, e.g. pattern='\(AC_\|ILT_\)', except that UNIX sed doesn't do
index 56caf60d3c81275b611137b9be01b16398225fd1..385a44fcfad81a64784185d232dcc952e54d7515 100644 (file)
@@ -38,14 +38,18 @@ Operation modes:
   -m, --macrodir=DIR       directory storing Autoconf's macro files
   -l, --localdir=DIR       directory storing the \`aclocal.m4' file
   -o, --output=FILE        save output in FILE (stdout is the default)
-  -W, --warnings=CATEGORY  report the warnings falling in CATEGORY
+  -W, --warnings=CATEGORY  report the warnings falling in CATEGORY [syntax]
 
 Warning categories include:
-  \`cross'      cross compilation issues
-  \`obsolete'   obsolete constructs
-  \`syntax'     dubious syntactic constructs
-  \`all'        all the warnings
-  \`error'      warnings are error
+  \`cross'        cross compilation issues
+  \`obsolete'     obsolete constructs
+  \`syntax'       dubious syntactic constructs
+  \`all'          all the warnings
+  \`noCATEGORY'   turn off the warnings on CATEGORY
+  \`none'         turn off all the warnings
+  \`error'        warnings are error
+
+The environment variable \`WARNINGS' is honored.
 
 Tracing:
   -t, --trace=MACRO     report the list of calls to MACRO
@@ -127,7 +131,9 @@ verbose=:
 
 # Parse command line.
 while test $# -gt 0 ; do
-  case "$1" in
+  optarg=`expr "$1" : '--[^=]*=\(.*\)' \| \
+               "$1" : '-.\(.*\)'`
+  case $1 in
     --version | --vers* | -V )
        echo "$version" ; exit 0 ;;
     --help | --h* | -h )
@@ -140,7 +146,7 @@ while test $# -gt 0 ; do
        shift;;
 
     --localdir=* | --l*=* )
-       localdir=`echo "$1" | sed -e 's/^[^=]*=//'`
+       localdir=$optarg
        shift ;;
     --localdir | --l* | -l )
        test $# = 1 && eval "$exit_missing_arg"
@@ -149,7 +155,7 @@ while test $# -gt 0 ; do
        shift ;;
 
     --macrodir=* | --m*=* )
-       AC_MACRODIR=`echo "$1" | sed -e 's/^[^=]*=//'`
+       AC_MACRODIR=$optarg
        shift ;;
     --macrodir | --m* | -m )
        test $# = 1 && eval "$exit_missing_arg"
@@ -169,8 +175,7 @@ while test $# -gt 0 ; do
        shift ;;
     --trace=* )
        task=trace
-       traces="$traces '"`echo "$1" |
-                          sed -e "s/^[^=]*=//;s/:.*//;s/'/'\\\\\\\\''/g"`"'"
+       traces="$traces '"`echo "$optarg" | sed "s/'/'\\\\\\\\''/g"`"'"
        shift ;;
     --initialization | -i )
        initialization=:
@@ -182,22 +187,22 @@ while test $# -gt 0 ; do
        outfile=$1
        shift ;;
     --output=* )
-       outfile=`echo "$1" | sed -e 's/^[^=]*=//'`
+       outfile=$optarg
        shift ;;
     -o* )
-       outfile=`expr "$1" : '-o\(.*\)'`
+       outfile=$optarg
        shift ;;
 
     --warnings | -W )
        test $# = 1 && eval "$exit_missing_arg"
        shift
-       warnings="$warnings "`echo $1 | sed -e 's/,/ /g'`
+       warnings=$warnings,$1
        shift ;;
     --warnings=* )
-       warnings="$warnings "`echo "$1" | sed -e 's/^[^=]*=//;s/,/ /g'`
+       warnings=$warnings,$optarg
        shift ;;
     -W* ) # People are used to -Wall, -Werror etc.
-       warnings="$warnings "`echo "$1" | sed -e 's/^-W//;s/,/ /g'`
+       warnings=$warnings,$optarg
        shift ;;
 
     -- )     # Stop option processing
@@ -214,8 +219,16 @@ while test $# -gt 0 ; do
   esac
 done
 
-# Support $WARNINGS.
-: ${warnings=`echo $WARNINGS | sed -e 's/,/ /g'`}
+# The warnings are the concatenation of 1. application's defaults,
+# 2. $WARNINGS, $3 command line options, in that order.
+# Set them in the order expected by the M4 macros: the converse.
+_ac_warnings=
+for warning in `IFS=,; echo syntax,$WARNINGS,$warnings | tr [A-Z] [a-z]`
+do
+  test -n $warning || continue
+  _ac_warnings="$warning"`test -n "$_ac_warnings" && echo ",$_ac_warnings"`
+done
+
 
 # Trap on 0 to stop playing with `rm'.
 $debug ||
@@ -283,10 +296,8 @@ case $task in
   ## Generate the `configure' script.  ##
   ## --------------------------------- ##
   script)
-  # Enable the requested warnings.
-  warnings_opt=`echo "$warnings" |
-                sed -e 's/\([^ ][^ ]*\)/-DAC_WARNING_ENABLE(\1) /g'`
-  $run_m4f $warnings_opt $infile >$tmp/configure || exit 2
+  # M4 expansion.
+  $run_m4f -D_AC_WARNINGS=$_ac_warnings $infile >$tmp/configure || exit 2
 
   # You could add your own prefixes to pattern if you wanted to check for
   # them too, e.g. pattern='\(AC_\|ILT_\)', except that UNIX sed doesn't do
index 2a06a7e025a100b5db5bd243974525d7121555ce..bb2afd15ba933598605fa4f050614cfbe984e71e 100644 (file)
@@ -909,13 +909,35 @@ for the standard output.
 @evindex WARNINGS
 Report the warnings related to @var{category} (which can actually be a
 comma separated list).  @xref{Reporting Messages}, macro
-@code{AC_DIAGNOSE}, for a comprehensive list of categories.  The special
-category @samp{all} will report all the warnings, and @samp{error}
-treats warnings as errors.
+@code{AC_DIAGNOSE}, for a comprehensive list of categories.  Special
+values include:
 
-The soon-do-be-standard environment variable @code{WARNINGS} is
-supported: it consists in a comma separated list of categories.  It is
-honored iff @option{--warnings} was not used.
+@table @samp
+@item all
+report all the warnings
+
+@item none
+report none
+
+@item error
+treats warnings as errors
+
+@item no@var{category}
+disable warnings falling into @var{category}
+@end table
+
+Warnings about @samp{syntax} are enabled by default, and the environment
+variable @code{WARNINGS}, a comma separated list of categories, is
+honored. @command{autoconf} will actually behave as if you had run
+
+@example
+autoconf --warnings=syntax,$WARNINGS,@var{categories}
+@end example
+
+@noindent
+If you want to disable @command{autoconf}'s defaults and @code{WARNING}
+but enable the warnings about obsolete constructs, use @samp{-W
+none,obsolete}.
 
 @item --trace=@var{macro}[:@var{format}]
 @itemx -t @var{macro}[:@var{format}]
@@ -1927,21 +1949,26 @@ Report the warnings related to @var{category} (which can actually be a
 comma separated list). Current categories include:
 
 @table @samp
-@item @samp{obsolete}
+@item obsolete
 report the uses of obsolete constructs
 
-@item @samp{all}
+@item all
 report all the warnings
 
-@item @samp{error}
+@item none
+report none
+
+@item error
 treats warnings as errors
+
+@item no@var{category}
+disable warnings falling into @var{category}
 @end table
 
-The soon-do-be-standard environment variable @code{WARNINGS} is
-supported: it consists in a comma separated list of categories.  It is
-honored iff @option{--warnings} was not used.
 @end table
 
+
+
 @node Autoheader Macros,  , autoheader Invocation, Configuration Headers
 @subsection Autoheader Macros
 
@@ -6286,7 +6313,7 @@ dubious syntactic constructs, incorrectly ordered macro calls.
 
 @defmac AC_WARNING (@var{message})
 @maindex WARNING
-Equivalent to @samp{AC_DIAGNOSE([], @var{message})}, but you are
+Equivalent to @samp{AC_DIAGNOSE([syntax], @var{message})}, but you are
 strongly encouraged to use a finer grained category.
 @end defmac
 
index a8373299afc91f54b837ea2615ef61b648ffcce2..d88d34f18cfd83328c1756cd98ff9a5a1118eefe 100644 (file)
@@ -2393,7 +2393,7 @@ rm -f confcache[]dnl
 # The name of shell var CACHE-ID must contain `_cv_' in order to get saved.
 # Should be dnl'ed.  Try to catch common mistakes.
 define([AC_CACHE_VAL],
-[ifelse(regexp([$2], [AC_DEFINE]), [-1],
+[ifelse(regexp([$2], [AC_DEFINE]), [-1], [],
                [AC_DIAGNOSE(syntax,
 [$0($1, ...): suspicious presence of an AC_DEFINE in the second argument, ]dnl
 [where no actions should be taken])])dnl
@@ -2500,9 +2500,29 @@ s,@$1@,,;t t])])
 # If the CATEGORY of warnings is enabled, expand IF_TRUE otherwise
 # IF-FALSE.  CATEGORY is enabled iff `AC_WARNING_ENABLE(CATEGORY)' or
 # `AC_WARNING_ENABLE(all)' is defined.
+#
+# The variable `_AC_WARNINGS' contains a comma separated list of
+# warnings which order is the converse from the one specified by
+# the user, i.e., if she specified `-W error,none,obsolete',
+# `_AC_WARNINGS' is `obsolete,none,error'.  We read it from left to
+# right, and:
+# - if none or noCATEGORY is met, run IF-FALSE
+# - if all or CATEGORY is met, run IF-TRUE
+# - if there is nothing left, run IF-FALSE.
 define([AC_WARNING_IFELSE],
-[ifdef([AC_WARNING_ENABLE($1)], [$2],
-       [ifdef([AC_WARNING_ENABLE(all)], [$2], [$3])])])
+[_AC_WARNING_IFELSE([$1], [$2], [$3], _AC_WARNINGS)])
+
+
+# _AC_WARNING_IFELSE(CATEGORY, IF-TRUE, IF-FALSE, WARNING1, ...)
+# --------------------------------------------------------------
+# Implementation of the loop described above.
+define([_AC_WARNING_IFELSE],
+[ifelse([$4],  [$1],   [$2],
+        [$4],  [all],  [$2],
+        [$4],  [],     [$3],
+        [$4],  [none], [$3],
+        [$4],  [no$1], [$3],
+        [$0([$1], [$2], [$3], m4_shiftn(4, $@))])])
 
 
 # _AC_DIAGNOSE(MESSAGE)
@@ -2527,7 +2547,7 @@ define([AC_DIAGNOSE],
 # -------------------
 # Report a MESSAGE to the user of autoconf if `-W' or `-W all' was
 # specified.
-define([AC_WARNING], [AC_DIAGNOSE([], [$1])])
+define([AC_WARNING], [AC_DIAGNOSE([syntax], [$1])])
 
 
 # AC_FATAL(MESSAGE, [EXIT-STATUS])