On 05/13/2013 12:28 PM, Eric Blake wrote:
Some of this needs to be imported into upstream gnulib.
I gave it a try, by installing the following.
I'll follow up on bug-gnulib with 7 other clang-related patches.
From 45fc031e607cb82dce777228d9334cdac16ca648 Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert(a)cs.ucla.edu>
Date: Wed, 15 May 2013 00:07:15 -0700
Subject: [PATCH 1/8] warnings: port to clang
Problem reported by Daniel P. Berrange via Eric Blake in
<
http://lists.gnu.org/archive/html/bug-gnulib/2013-05/msg00055.html>.
* m4/warnings.m4 (gl_UNKNOWN_WARNINGS_ARE_ERRORS): New macro.
(gl_WARN_ADD): Use it.
---
ChangeLog | 8 ++++++++
m4/warnings.m4 | 15 ++++++++++++---
2 files changed, 20 insertions(+), 3 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 08f2fe0..b7aceaa 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2013-05-15 Paul Eggert <eggert(a)cs.ucla.edu>
+
+ warnings: port to clang
+ Problem reported by Daniel P. Berrange via Eric Blake in
+ <
http://lists.gnu.org/archive/html/bug-gnulib/2013-05/msg00055.html>.
+ * m4/warnings.m4 (gl_UNKNOWN_WARNINGS_ARE_ERRORS): New macro.
+ (gl_WARN_ADD): Use it.
+
2013-05-11 Jim Meyering <meyering(a)fb.com>
quotearg: do not read beyond end of buffer
diff --git a/m4/warnings.m4 b/m4/warnings.m4
index 4b2ac38..1848732 100644
--- a/m4/warnings.m4
+++ b/m4/warnings.m4
@@ -1,4 +1,4 @@
-# warnings.m4 serial 7
+# warnings.m4 serial 8
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,
@@ -27,7 +27,7 @@ AC_DEFUN([gl_COMPILER_OPTION_IF],
AS_VAR_PUSHDEF([gl_Flags], [_AC_LANG_PREFIX[]FLAGS])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]), [" $1"])
+ gl_AS_VAR_APPEND(m4_defn([gl_Flags]), [" $gl_unknown_warnings_are_errors
$1"])
AC_COMPILE_IFELSE([m4_default([$4], [AC_LANG_PROGRAM([])])],
[AS_VAR_SET(gl_Warn, [yes])],
[AS_VAR_SET(gl_Warn, [no])])
@@ -38,6 +38,14 @@ AS_VAR_POPDEF([gl_Flags])dnl
AS_VAR_POPDEF([gl_Warn])dnl
])
+# gl_UNKNOWN_WARNINGS_ARE_ERRORS
+# ------------------------------
+# Clang doesn't complain about unknown warning options unless one also
+# specifies -Wunknown-warning-option -Werror. Detect this.
+AC_DEFUN([gl_UNKNOWN_WARNINGS_ARE_ERRORS],
+[gl_COMPILER_OPTION_IF([-Werror -Wunknown-warning-option],
+ [gl_unknown_warnings_are_errors='-Wunknown-warning-option -Werror'],
+ [gl_unknown_warnings_are_errors=])])
# gl_WARN_ADD(OPTION, [VARIABLE = WARN_CFLAGS],
# [PROGRAM = AC_LANG_PROGRAM()])
@@ -47,7 +55,8 @@ AS_VAR_POPDEF([gl_Warn])dnl
#
# If VARIABLE is a variable name, AC_SUBST it.
AC_DEFUN([gl_WARN_ADD],
-[gl_COMPILER_OPTION_IF([$1],
+[AC_REQUIRE([gl_UNKNOWN_WARNINGS_ARE_ERRORS])
+gl_COMPILER_OPTION_IF([$1],
[gl_AS_VAR_APPEND(m4_if([$2], [], [[WARN_CFLAGS]], [[$2]]), [" $1"])],
[],
[$3])
--
1.7.11.7