Add a fallthrough macro.

This macro defers to __attribute__((fallthrough)) on GCC (and
clang).  Previously we had been using GCC's magic /* fallthrough */
comments, but clang very sensibly doesn't accept those.

Since not all compiler recognize it, we only define it when our
configure script detects that it works.

Part of a fix for 34078.
This commit is contained in:
Nick Mathewson
2020-05-06 10:24:21 -04:00
parent d380acaeca
commit 6c3c94357c
2 changed files with 22 additions and 0 deletions
+6
View File
@@ -50,6 +50,12 @@
#define CHECK_SCANF(formatIdx, firstArg)
#endif /* defined(__GNUC__) */
#if defined(HAVE_ATTR_FALLTHROUGH)
#define FALLTHROUGH __attribute__((fallthrough))
#else
#define FALLTHROUGH
#endif
/* What GCC do we have? */
#ifdef __GNUC__
#define GCC_VERSION (__GNUC__ * 100 + __GNUC_MINOR__)