clang-10: ignore fallthrough warning in generated code 75/14275/9
authorCheyenne Wills <cwills@sinenomine.net>
Thu, 23 Jul 2020 21:43:42 +0000 (15:43 -0600)
committerBenjamin Kaduk <kaduk@mit.edu>
Mon, 27 Jul 2020 16:23:15 +0000 (12:23 -0400)
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>

CODING
src/cf/osconf.m4
src/comerr/error_table.y
src/uss/Makefile.in

diff --git a/CODING b/CODING
index bac7490..bff3c92 100644 (file)
--- 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
index 12125ce..53ded31 100644 (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)
index 05f524b..6690c65 100644 (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
index 7a5fe4f..aa1ddb7 100644 (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