bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] warnings: extend -Wno-foo handling to work through shell vars


From: Eric Blake
Subject: [PATCH] warnings: extend -Wno-foo handling to work through shell vars
Date: Thu, 15 Aug 2013 13:24:47 -0600

Reported by Paul Eggert.  Common usage is to do:

for w in $list; do
  gl_WARN_ADD([$w])
done

which means we have to be polymorphic to shell code (similar to
how AS_VAR_SET is polymorphic).

* m4/warnings.m4 (gl_COMPILER_OPTION_IF): Make polymorphic.

Signed-off-by: Eric Blake <address@hidden>
---
 ChangeLog      |  5 +++++
 m4/warnings.m4 | 12 ++++++++++--
 2 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 5416541..fc4fb31 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2013-08-15  Eric Blake  <address@hidden>
+
+       warnings: extend -Wno-foo handling to work through shell vars
+       * m4/warnings.m4 (gl_COMPILER_OPTION_IF): Make polymorphic.
+
 2013-08-14  Eric Blake  <address@hidden>

        warnings: check -Wfoo rather than -Wno-foo
diff --git a/m4/warnings.m4 b/m4/warnings.m4
index afde4c5..cbe08b5 100644
--- a/m4/warnings.m4
+++ b/m4/warnings.m4
@@ -1,4 +1,4 @@
-# warnings.m4 serial 8
+# warnings.m4 serial 9
 dnl Copyright (C) 2008-2013 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -25,16 +25,24 @@ m4_ifdef([AS_VAR_APPEND],
 AC_DEFUN([gl_COMPILER_OPTION_IF],
 [AS_VAR_PUSHDEF([gl_Warn], [gl_cv_warn_[]_AC_LANG_ABBREV[]_$1])dnl
 AS_VAR_PUSHDEF([gl_Flags], [_AC_LANG_PREFIX[]FLAGS])dnl
+AS_LITERAL_IF([$1],
+  [m4_pushdef([gl_Positive], m4_bpatsubst([$1], [^-Wno-], [-W]))],
+  [gl_positive="$1"
+case $gl_positive in
+  -Wno-*) gl_positive=`echo ".$gl_positive" | sed 's/^.//; s/^-Wno-/-W/'`;;
+esac
+m4_pushdef([gl_Positive], [$gl_positive])])dnl
 AC_CACHE_CHECK([whether _AC_LANG compiler handles $1], m4_defn([gl_Warn]), [
   gl_save_compiler_FLAGS="$gl_Flags"
   gl_AS_VAR_APPEND(m4_defn([gl_Flags]),
-    [" $gl_unknown_warnings_are_errors ]m4_bpatsubst([$1], [^-Wno-], [-W])["])
+    [" $gl_unknown_warnings_are_errors ]m4_defn([gl_Positive])["])
   AC_COMPILE_IFELSE([m4_default([$4], [AC_LANG_PROGRAM([])])],
                     [AS_VAR_SET(gl_Warn, [yes])],
                     [AS_VAR_SET(gl_Warn, [no])])
   gl_Flags="$gl_save_compiler_FLAGS"
 ])
 AS_VAR_IF(gl_Warn, [yes], [$2], [$3])
+m4_popdef([gl_Positive])dnl
 AS_VAR_POPDEF([gl_Flags])dnl
 AS_VAR_POPDEF([gl_Warn])dnl
 ])
-- 
1.8.3.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]