diff options
author | Nick Mathewson <nickm@torproject.org> | 2020-05-06 10:24:21 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2020-05-06 15:08:02 -0400 |
commit | 6c3c94357c196681ceda773425e18161da8cfdef (patch) | |
tree | 5c16d080bf7eee8438aaf702a57c1d61fb1eb3dc /src/lib/cc | |
parent | d380acaecad5f554f7294cfcd7fbf100f9bbaca3 (diff) | |
download | tor-6c3c94357c196681ceda773425e18161da8cfdef.tar.gz tor-6c3c94357c196681ceda773425e18161da8cfdef.zip |
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.
Diffstat (limited to 'src/lib/cc')
-rw-r--r-- | src/lib/cc/compat_compiler.h | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/lib/cc/compat_compiler.h b/src/lib/cc/compat_compiler.h index 3a0f307186..fbe6a38f1f 100644 --- a/src/lib/cc/compat_compiler.h +++ b/src/lib/cc/compat_compiler.h @@ -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__) |