Is your feature request related to a problem? Please describe.
It's useful to have a fallthrough macro that can be used in switch-case blocks, to indicate that falling through is intended.
The CDT parser already supports using a comment for this, like // fallthrough, but that doesn't help if your project (like the Linux kernel source) already uses a macro for this.
In their case resolving to __attribute__((__fallthrough__)), which CDT doesn't support either (see also this older bug: https://bugs.eclipse.org/bugs/show_bug.cgi?id=567227 ).
For C++ [[fallthrough]] is supported, but that doesn't help for C.
Describe the solution you'd like
Currently Linux has this code:
#if __has_attribute(__fallthrough__)
# define fallthrough __attribute__((__fallthrough__))
#else
# define fallthrough do {} while (0) /* fallthrough */
#endif
in a header.
Used like
switch (*data) {
default:
// ... some code ...
fallthrough; /* report timeout */
case 0xfc:
// ... some more code ...
I could (locally) adjust it to
#ifdef __CDT_PARSER__
# define fallthrough __CDT_FALLTHROUGH__
#elif __has_attribute(__fallthrough__)
// ...
.. if __CDT_FALLTHROUGH__ (or something similar) existed.
Describe alternatives you've considered
Maybe just supporting __attribute__((__fallthrough__)) directly would be even better. Or both?
Is your feature request related to a problem? Please describe.
It's useful to have a
fallthroughmacro that can be used in switch-case blocks, to indicate that falling through is intended.The CDT parser already supports using a comment for this, like
// fallthrough, but that doesn't help if your project (like the Linux kernel source) already uses a macro for this.In their case resolving to
__attribute__((__fallthrough__)), which CDT doesn't support either (see also this older bug: https://bugs.eclipse.org/bugs/show_bug.cgi?id=567227 ).For C++
[[fallthrough]]is supported, but that doesn't help for C.Describe the solution you'd like
Currently Linux has this code:
in a header.
Used like
I could (locally) adjust it to
.. if
__CDT_FALLTHROUGH__(or something similar) existed.Describe alternatives you've considered
Maybe just supporting
__attribute__((__fallthrough__))directly would be even better. Or both?