From e5f44f6e9af643cab3a66216dff901e0a4c5eda8 Mon Sep 17 00:00:00 2001 From: Cheyenne Wills Date: Thu, 23 Jul 2020 15:43:42 -0600 Subject: [PATCH] clang-10: ignore fallthrough warning in generated code Clang-10 will not recognize '/* fall through */' as an indicator to turn off the fallthrough warning due to the lack of a 'break' in a case statement. Code generated by flex uses the '/* fall through */' comments to turn off compiler warnings for fallthroughs in case statements. For code generated by flex, ignore the implicit-fallthrough via pragma or disable the warning via a compile time flag. Add new env variable "CFLAGS_NOIMPLICIT_FALLTHROUGH" to selectively disable the compile check in Makefiles when checking is enabled. Change-Id: I4c054defda03daa2aeb645ae2271dfa0cb54925f Reviewed-on: https://gerrit.openafs.org/14275 Reviewed-by: Andrew Deason Reviewed-by: Benjamin Kaduk Tested-by: BuildBot --- CODING | 5 ++++- src/cf/osconf.m4 | 4 ++++ src/comerr/error_table.y | 5 +++++ src/uss/Makefile.in | 2 +- 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/CODING b/CODING index bac7490..bff3c92 100644 --- a/CODING +++ b/CODING @@ -317,7 +317,10 @@ If you add a new warning inhibition, please also add it to the list below. Inhibited warnings ------------------ - +uss/lex.i : fallthrough : clang fallthrough, flex generated code +comerr/et_lex.lex.l : fallthrough : clang fallthrough, flex generated code + pragma set to ignored where included in + error_table.y afs/afs_syscall.c : old-style : strict-proto : all (ukernel) : syscall pointer issues diff --git a/src/cf/osconf.m4 b/src/cf/osconf.m4 index 12125ce..53ded31 100644 --- a/src/cf/osconf.m4 +++ b/src/cf/osconf.m4 @@ -622,6 +622,7 @@ CFLAGS_NOERROR= CFLAGS_NOSTRICT=-fno-strict-aliasing CFLAGS_NOUNUSED= CFLAGS_NOOLDSTYLE= +CFLAGS_NOIMPLICIT_FALLTHROUGH= XCFLAGS_NOCHECKING="$XCFLAGS" if test "x$GCC" = "xyes"; then @@ -635,6 +636,8 @@ if test "x$GCC" = "xyes"; then CFLAGS_NOERROR="-Wno-error" CFLAGS_NOUNUSED="-Wno-unused" CFLAGS_NOOLDSTYLE="-Wno-old-style-definition" + AX_APPEND_COMPILE_FLAGS([-Wno-implicit-fallthrough], + [CFLAGS_NOIMPLICIT_FALLTHROUGH]) AC_DEFINE(IGNORE_SOME_GCC_WARNINGS, 1, [define to disable some gcc warnings in warnings-as-errors mode]) else CFLAGS_NOSTRICT= @@ -715,6 +718,7 @@ AC_SUBST(CFLAGS_NOERROR) AC_SUBST(CFLAGS_NOSTRICT) AC_SUBST(CFLAGS_NOUNUSED) AC_SUBST(CFLAGS_NOOLDSTYLE) +AC_SUBST(CFLAGS_NOIMPLICIT_FALLTHROUGH) AC_SUBST(CFLAGS_WERROR) AC_SUBST(XCFLAGS64) AC_SUBST(XLDFLAGS) diff --git a/src/comerr/error_table.y b/src/comerr/error_table.y index 05f524b..6690c65 100644 --- a/src/comerr/error_table.y +++ b/src/comerr/error_table.y @@ -389,6 +389,11 @@ int char_to_1num(char c) exit (1); } +#if defined(IGNORE_SOME_GCC_WARNINGS) && defined(__clang__) && defined(HAVE_FUNC_ATTRIBUTE_FALLTHROUGH) +/* flex generates fallthroughs in case blocks that get flagged by clang */ +# pragma GCC diagnostic ignored "-Wimplicit-fallthrough" +#endif + #ifdef AFS_NT40_ENV #include "et_lex.lex_nt.c" #else diff --git a/src/uss/Makefile.in b/src/uss/Makefile.in index 7a5fe4f..aa1ddb7 100644 --- a/src/uss/Makefile.in +++ b/src/uss/Makefile.in @@ -48,7 +48,7 @@ uss: uss.o ${OBJS} $(LIBS) uss.o: uss.c AFS_component_version_number.c -CFLAGS_lex.yy.o = @CFLAGS_NOUNUSED@ @CFLAGS_NOOLDSTYLE@ +CFLAGS_lex.yy.o = @CFLAGS_NOUNUSED@ @CFLAGS_NOOLDSTYLE@ @CFLAGS_NOIMPLICIT_FALLTHROUGH@ lex.yy.o : lex.yy.c y.tab.c lex.yy.c : lex.l -- 1.9.4