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 <adeason@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
This commit is contained in:
Cheyenne Wills 2020-07-23 15:43:42 -06:00 committed by Benjamin Kaduk
parent 16f1b2f894
commit e5f44f6e9a
4 changed files with 14 additions and 2 deletions

5
CODING
View File

@ -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

View File

@ -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)

View File

@ -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

View File

@ -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