summaryrefslogtreecommitdiff
path: root/m4/ax_compiler_flags_cxxflags.m4
diff options
context:
space:
mode:
authorPhilip Withnall <philip.withnall@collabora.co.uk>2015-02-20 17:51:03 +0000
committerPhilip Withnall <philip.withnall@collabora.co.uk>2015-02-23 09:36:19 +0000
commit8b46e05f74d7aeca67176597d567a9bc4c5b8070 (patch)
tree0e869991e284e60d376bed79c3e887a219830ef4 /m4/ax_compiler_flags_cxxflags.m4
parentaeb28412ca48ee0685561f6688c6f00a423d944f (diff)
downloadautoconf-archive-8b46e05f74d7aeca67176597d567a9bc4c5b8070.tar.gz
ax_compiler_flags: Automate addition of -Wno-error=* flags
We need to add a -Wno-error=* flag for each -Wno-* flag as some compilers will re-enable the warning as an error if -Wall is passed in the user’s CFLAGS after we’ve specific -Werror. Previously this was done manually for the -Wno-* flags in AX_COMPILER_FLAGS_CFLAGS and AX_COMPILER_FLAGS_CXXFLAGS. However, this ignored the cases where the user was passing -Wno-* flags as extra-flags to the macros. Factor this out and automate it so -Wno-error=* flags will be tested and appended for any -Wno-* flag specified by the user in extra-flags.
Diffstat (limited to 'm4/ax_compiler_flags_cxxflags.m4')
-rw-r--r--m4/ax_compiler_flags_cxxflags.m423
1 files changed, 15 insertions, 8 deletions
diff --git a/m4/ax_compiler_flags_cxxflags.m4 b/m4/ax_compiler_flags_cxxflags.m4
index 6031a6f..d3e872b 100644
--- a/m4/ax_compiler_flags_cxxflags.m4
+++ b/m4/ax_compiler_flags_cxxflags.m4
@@ -26,7 +26,7 @@
# and this notice are preserved. This file is offered as-is, without any
# warranty.
-#serial 2
+#serial 3
AC_DEFUN([AX_COMPILER_FLAGS_CXXFLAGS],[
AX_REQUIRE_DEFINED([AX_APPEND_COMPILE_FLAGS])
@@ -56,10 +56,6 @@ AC_DEFUN([AX_COMPILER_FLAGS_CXXFLAGS],[
$3 dnl
],ax_warn_cxxflags_variable,[$ax_compiler_flags_test])
- # In the flags below, when disabling specific flags, always add *both*
- # -Wno-foo and -Wno-error=foo. This fixes the situation where (for example)
- # we enable -Werror, disable a flag, and a build bot passes CFLAGS=-Wall,
- # which effectively turns that flag back on again as an error.
AS_IF([test "$ax_enable_compile_warnings" != "no"],[
# "minimum" flags
AX_APPEND_COMPILE_FLAGS([ dnl
@@ -78,9 +74,7 @@ AC_DEFUN([AX_COMPILER_FLAGS_CXXFLAGS],[
-Wmissing-declarations dnl
-Wredundant-decls dnl
-Wno-unused-parameter dnl
- -Wno-error=unused-parameter dnl
-Wno-missing-field-initializers dnl
- -Wno-error=missing-field-initializers dnl
-Wformat=2 dnl
-Wcast-align dnl
-Wformat-nonliteral dnl
@@ -99,7 +93,6 @@ AC_DEFUN([AX_COMPILER_FLAGS_CXXFLAGS],[
-Warray-bounds dnl
-Wreturn-type dnl
-Wno-overloaded-virtual dnl
- -Wno-error=overloaded-virtual dnl
$5 dnl
],ax_warn_cxxflags_variable,[$ax_compiler_flags_test])
])
@@ -126,6 +119,20 @@ AC_DEFUN([AX_COMPILER_FLAGS_CXXFLAGS],[
],ax_warn_cxxflags_variable,[$ax_compiler_flags_test])
])
+ # In the flags below, when disabling specific flags, always add *both*
+ # -Wno-foo and -Wno-error=foo. This fixes the situation where (for example)
+ # we enable -Werror, disable a flag, and a build bot passes CXXFLAGS=-Wall,
+ # which effectively turns that flag back on again as an error.
+ for flag in $ax_warn_cxxflags_variable; do
+ AS_CASE([$flag],
+ [-Wno-*=*],[],
+ [-Wno-*],[
+ AX_APPEND_COMPILE_FLAGS([-Wno-error=${flag:5}],
+ ax_warn_cxxflags_variable,
+ [$ax_compiler_flags_test])
+ ])
+ done
+
AC_LANG_POP([C++])
# Substitute the variables