summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog16
-rw-r--r--m4/manywarnings.m412
-rw-r--r--m4/warnings.m447
3 files changed, 63 insertions, 12 deletions
diff --git a/ChangeLog b/ChangeLog
index cae6c7df94..8282f2e3e5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+2017-08-06 Bruno Haible <bruno@clisp.org>
+
+ warnings, manywarnings: Add support for multiple languages, not just C.
+ * warnings.m4 (gl_UNKNOWN_WARNINGS_ARE_ERRORS_IMPL): Renamed from
+ gl_UNKNOWN_WARNINGS_ARE_ERRORS.
+ (gl_UNKNOWN_WARNINGS_ARE_ERRORS(C)): New macro.
+ (gl_UNKNOWN_WARNINGS_ARE_ERRORS(C++)): New macro.
+ (gl_UNKNOWN_WARNINGS_ARE_ERRORS): Dispatch to
+ gl_UNKNOWN_WARNINGS_ARE_ERRORS(_AC_LANG).
+ (gl_WARN_ADD): Require the gl_UNKNOWN_WARNINGS_ARE_ERRORS specialization
+ of the current language. If C++ is the current language, modify
+ WARN_CXXFLAGS instead of WARN_CFLAGS.
+ * manywarnings.m4 (gl_MANYWARN_ALL_GCC(C)): New macro, extracted from
+ gl_MANYWARN_ALL_GCC.
+ (gl_MANYWARN_ALL_GCC): Dispatch to gl_MANYWARN_ALL_GCC(_AC_LANG).
+
2017-08-06 Markus Armbruster <armbru@pond.sub.org>
git-version-gen: Fix for tags containing '-'
diff --git a/m4/manywarnings.m4 b/m4/manywarnings.m4
index 6a8939b2c1..3124b1e507 100644
--- a/m4/manywarnings.m4
+++ b/m4/manywarnings.m4
@@ -1,4 +1,4 @@
-# manywarnings.m4 serial 10
+# manywarnings.m4 serial 11
dnl Copyright (C) 2008-2017 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -33,8 +33,16 @@ AC_DEFUN([gl_MANYWARN_COMPLEMENT],
# Add all documented GCC warning parameters to variable VARIABLE.
# Note that you need to test them using gl_WARN_ADD if you want to
# make sure your gcc understands it.
+#
+# The effects of this macro depend on the current language (_AC_LANG).
AC_DEFUN([gl_MANYWARN_ALL_GCC],
+[_AC_LANG_DISPATCH([$0], _AC_LANG, $@)])
+
+# Specialization for _AC_LANG = C. This macro can be AC_REQUIREd.
+AC_DEFUN([gl_MANYWARN_ALL_GCC(C)],
[
+ AC_LANG_PUSH([C])
+
dnl First, check for some issues that only occur when combining multiple
dnl gcc warning categories.
AC_REQUIRE([AC_PROG_CC])
@@ -303,4 +311,6 @@ AC_DEFUN([gl_MANYWARN_ALL_GCC],
fi
$1=$gl_manywarn_set
+
+ AC_LANG_POP([C])
])
diff --git a/m4/warnings.m4 b/m4/warnings.m4
index e697174edd..aa2735b77f 100644
--- a/m4/warnings.m4
+++ b/m4/warnings.m4
@@ -1,4 +1,4 @@
-# warnings.m4 serial 11
+# warnings.m4 serial 12
dnl Copyright (C) 2008-2017 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -20,10 +20,12 @@ m4_ifdef([AS_VAR_APPEND],
# -----------------------------------------------------------------
# Check if the compiler supports OPTION when compiling PROGRAM.
#
-# FIXME: gl_Warn must be used unquoted until we can assume Autoconf
-# 2.64 or newer.
+# The effects of this macro depend on the current language (_AC_LANG).
AC_DEFUN([gl_COMPILER_OPTION_IF],
-[AS_VAR_PUSHDEF([gl_Warn], [gl_cv_warn_[]_AC_LANG_ABBREV[]_$1])dnl
+[
+dnl FIXME: gl_Warn must be used unquoted until we can assume Autoconf
+dnl 2.64 or newer.
+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]))],
@@ -51,27 +53,50 @@ AS_VAR_POPDEF([gl_Warn])dnl
# ------------------------------
# Clang doesn't complain about unknown warning options unless one also
# specifies -Wunknown-warning-option -Werror. Detect this.
+#
+# The effects of this macro depend on the current language (_AC_LANG).
AC_DEFUN([gl_UNKNOWN_WARNINGS_ARE_ERRORS],
+[_AC_LANG_DISPATCH([$0], _AC_LANG, $@)])
+
+# Specialization for _AC_LANG = C. This macro can be AC_REQUIREd.
+AC_DEFUN([gl_UNKNOWN_WARNINGS_ARE_ERRORS(C)],
+[
+ AC_LANG_PUSH([C])
+ gl_UNKNOWN_WARNINGS_ARE_ERRORS_IMPL
+ AC_LANG_POP([C])
+])
+
+# Specialization for _AC_LANG = C++. This macro can be AC_REQUIREd.
+AC_DEFUN([gl_UNKNOWN_WARNINGS_ARE_ERRORS(C++)],
+[
+ AC_LANG_PUSH([C++])
+ gl_UNKNOWN_WARNINGS_ARE_ERRORS_IMPL
+ AC_LANG_POP([C++])
+])
+
+AC_DEFUN([gl_UNKNOWN_WARNINGS_ARE_ERRORS_IMPL],
[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],
+# gl_WARN_ADD(OPTION, [VARIABLE = WARN_CFLAGS/WARN_CXXFLAGS],
# [PROGRAM = AC_LANG_PROGRAM()])
-# ---------------------------------------------
-# Adds parameter to WARN_CFLAGS if the compiler supports it when
-# compiling PROGRAM. For example, gl_WARN_ADD([-Wparentheses]).
+# -----------------------------------------------------------
+# Adds parameter to WARN_CFLAGS/WARN_CXXFLAGS if the compiler supports it
+# when compiling PROGRAM. For example, gl_WARN_ADD([-Wparentheses]).
#
# If VARIABLE is a variable name, AC_SUBST it.
+#
+# The effects of this macro depend on the current language (_AC_LANG).
AC_DEFUN([gl_WARN_ADD],
-[AC_REQUIRE([gl_UNKNOWN_WARNINGS_ARE_ERRORS])
+[AC_REQUIRE([gl_UNKNOWN_WARNINGS_ARE_ERRORS(]_AC_LANG[)])
gl_COMPILER_OPTION_IF([$1],
- [gl_AS_VAR_APPEND(m4_if([$2], [], [[WARN_CFLAGS]], [[$2]]), [" $1"])],
+ [gl_AS_VAR_APPEND(m4_if([$2], [], [[WARN_]_AC_LANG_PREFIX[FLAGS]], [[$2]]), [" $1"])],
[],
[$3])
m4_ifval([$2],
[AS_LITERAL_IF([$2], [AC_SUBST([$2])])],
- [AC_SUBST([WARN_CFLAGS])])dnl
+ [AC_SUBST([WARN_]_AC_LANG_PREFIX[FLAGS])])dnl
])
# Local Variables: