From d6c85cff9df027ea3972f021d674f96b9bd9d9db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= Date: Wed, 17 Feb 2021 10:27:06 +0100 Subject: build: Check for -Wimplicit-fallthrough=5 separately MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit GCC accepts the =5, which means it doesn't try to parse any comments and only accepts the fallthrough attribute in code. Clang does not ever parse any comments and always wants the fallthrough attribute anyway. Clang also doesn't accept the =n parameter for -Wimplicit-fallthrough. Test for =5 separately and use it if supported and fall back to just -Wimplicit-fallthrough otherwise. Signed-off-by: Timm Bäder --- configure.ac | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'configure.ac') diff --git a/configure.ac b/configure.ac index d345495d..e56aeb6a 100644 --- a/configure.ac +++ b/configure.ac @@ -519,6 +519,18 @@ CFLAGS="$old_CFLAGS"]) AM_CONDITIONAL(HAVE_IMPLICIT_FALLTHROUGH_WARNING, [test "x$ac_cv_implicit_fallthrough" != "xno"]) +# Check whether the compiler additionally accepts -Wimplicit-fallthrough=5 +# GCC accepts this and 5 means "don't parse any fallthrough comments and +# only accept the fallthrough attribute" +AC_CACHE_CHECK([whether the compiler accepts -Wimplicit-fallthrough=5], ac_cv_implicit_fallthrough_5, [dnl +old_CFLAGS="$CFLAGS" +CFLAGS="$CFLAGS -Wimplicit-fallthrough=5 -Werror" +AC_COMPILE_IFELSE([AC_LANG_SOURCE([])], + ac_cv_implicit_fallthrough_5=yes, ac_cv_implicit_fallthrough_5=no) +CFLAGS="$old_CFLAGS"]) +AM_CONDITIONAL(HAVE_IMPLICIT_FALLTHROUGH_5_WARNING, + [test "x$ac_cv_implicit_fallthrough_5" != "xno"]) + # Assume the fallthrough attribute is supported if -Wimplict-fallthrough is supported if test "$ac_cv_implicit_fallthrough" = "yes"; then AC_DEFINE([HAVE_FALLTHROUGH], [1], -- cgit v1.2.1