Skip to content

Commit

Permalink
BUILD: Test for -Wfoobar instead of -Wno-foobar
Browse files Browse the repository at this point in the history
gcc is more tolerant at allowing stray, unsupported -Wno-foobar.
So if we want to test whether a compiler support -Wno-foobar, we need
to test for -Wfoobar instead.
  • Loading branch information
DrMcCoy committed Dec 1, 2015
1 parent 0f9df1a commit 2d2e687
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
10 changes: 5 additions & 5 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ if test "x$with_warnings" = "xno"; then
WARN_C_CXX=""
WARN_CXX=""

AX_CHECK_COMPILER_FLAGS_VAR([C], [WARN_C_CXX], [-Wno-deprecated-declarations])
AX_CHECK_COMPILER_FLAGS_VAR([C], [WARN_C_CXX], [-Wdeprecated-declarations], [-Wno-deprecated-declarations])
else
WARN_C_CXX="-Wall"
AX_CHECK_COMPILER_FLAGS_VAR([C], [WARN_C_CXX], [-Wignored-qualifiers])
Expand All @@ -56,13 +56,13 @@ else
AX_CHECK_COMPILER_FLAGS_VAR([C], [WARN_C_CXX], [-Wuninitialized])
AX_CHECK_COMPILER_FLAGS_VAR([C], [WARN_C_CXX], [-Wunused-parameter])
AX_CHECK_COMPILER_FLAGS_VAR([C], [WARN_C_CXX], [-Wunused-but-set-parameter])
AX_CHECK_COMPILER_FLAGS_VAR([C], [WARN_C_CXX], [-Wno-deprecated-declarations])
AX_CHECK_COMPILER_FLAGS_VAR([C], [WARN_C_CXX], [-Wno-long-long])
AX_CHECK_COMPILER_FLAGS_VAR([C], [WARN_C_CXX], [-Wdeprecated-declarations], [-Wno-deprecated-declarations])
AX_CHECK_COMPILER_FLAGS_VAR([C], [WARN_C_CXX], [-Wlong-long], [-Wno-long-long])

WARN_CXX=""
AX_CHECK_COMPILER_FLAGS_VAR([C++], [WARN_CXX], [-Wnon-virtual-dtor])
AX_CHECK_COMPILER_FLAGS_VAR([C++], [WARN_CXX], [-Wno-overloaded-virtual])
AX_CHECK_COMPILER_FLAGS_VAR([C++], [WARN_CXX], [-Wno-c++11-long-long])
AX_CHECK_COMPILER_FLAGS_VAR([C++], [WARN_CXX], [-Woverloaded-virtual], [-Wno-overloaded-virtual])
AX_CHECK_COMPILER_FLAGS_VAR([C++], [WARN_CXX], [-Wc++11-long-long], [-Wno-c++11-long-long])
fi

AC_SUBST(WARN_C_CXX)
Expand Down
17 changes: 13 additions & 4 deletions m4/ax_check_compiler_flags_var.m4
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
#serial 1000
dnl @synopsis AX_CHECK_COMPILER_FLAGS_VAR(language, variable, flag)
dnl @synopsis AX_CHECK_COMPILER_FLAGS_VAR(language, variable, flag-to-test, flag-to-use)
dnl
dnl @summary Check whether the compiler for this language accepts this flag, and
dnl add it to the variable if it does
dnl @summary Check whether the compiler for this language accepts flag-to-test,
dnl and add flag-to-add to the variable if it does. flag-to-test and
dnl flag-to-add can be different, because a compiler might allow
dnl a stray -Wno-foobar, while not actually supporting it. In this
dnl case, flag-to-test should be -Wfoobar. If flag-to-use is empty
dnl flag-to-test will be used.
dnl
dnl Depends on the AX_CHECK_COMPILER_FLAGS macro.
dnl
Expand All @@ -14,7 +18,12 @@ dnl @license Creative Commons CC0 1.0 Universal Public Domain Dedication
AC_DEFUN([AX_CHECK_COMPILER_FLAGS_VAR], [
AC_LANG_PUSH([$1])
AX_CHECK_COMPILER_FLAGS([$3], [-Werror], AS_VAR_APPEND([$2], [" $3"]))
FLAG_TO_USE="$4"
if test -z "$FLAG_TO_USE"; then
FLAG_TO_USE="$3"
fi
AX_CHECK_COMPILER_FLAGS([$3], [-Werror], AS_VAR_APPEND([$2], [" $FLAG_TO_USE"]))
AC_LANG_POP([$1])
])

0 comments on commit 2d2e687

Please sign in to comment.