diff options
author | Denis Ovsienko <denis@ovsienko.info> | 2017-07-21 22:04:15 +0100 |
---|---|---|
committer | Denis Ovsienko <denis@ovsienko.info> | 2017-07-22 19:33:49 +0100 |
commit | 6df678ca315946ed6190bc8fe0a80f3c36d246c4 (patch) | |
tree | bf24ecf12b3f7a8c9255f229ba956ccc0554f854 /netdissect-stdinc.h | |
parent | 11fcafcf6928d793411ae3dba9af324e3d027bb2 (diff) | |
download | tcpdump-6df678ca315946ed6190bc8fe0a80f3c36d246c4.tar.gz |
Check for __attribute__ ((fallthrough)) (GCC 7).
The documentation claims that recent GCC is now better by default at
spotting cases of code flow falling through (which is true) and that it
avoids false positives by matching nearby source code comments with
regexps. However, the latter feature doesn't seem to work as reliably
as the manual describes it, so let's have a macro for this purpose.
Tested to work on:
* x86_64, Fedora 26, GCC 7.1.1 (w/__attribute__, w/fallthrough)
* x86_64, Ubuntu 16.04, GCC 5.4.0 (w/__attribute__, w/o fallthrough)
* x86_64, FreeBSD 11.0, CLang 3.8.0 (w/__attribute__, w/o fallthrough)
* SPARC, Solaris 10, SolStudio 12.4 (w/__attribute__, w/o fallthrough)
* SPARC, Solaris 10, SunStudio 11 (w/o __attribute__)
Diffstat (limited to 'netdissect-stdinc.h')
-rw-r--r-- | netdissect-stdinc.h | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/netdissect-stdinc.h b/netdissect-stdinc.h index c7070f0a..fb385fb9 100644 --- a/netdissect-stdinc.h +++ b/netdissect-stdinc.h @@ -401,4 +401,10 @@ struct in6_addr { #define max(a,b) ((b)>(a)?(b):(a)) #endif +#ifdef __ATTRIBUTE___FALLTHROUGH_OK +# define ND_FALL_THROUGH __attribute__ ((fallthrough)) +#else +# define ND_FALL_THROUGH +#endif /* __ATTRIBUTE___FALLTHROUGH_OK */ + #endif /* netdissect_stdinc_h */ |