clang -Wimplicit-fallthrough and missing breaks

Stephan Bergmann sbergman at redhat.com
Mon May 9 09:34:49 UTC 2016


On 05/09/2016 10:54 AM, Caolán McNamara wrote:
> Does the clang version we use for all the spiffy warnings support
> -Wimplicit-fallthrough ?
>
> I see firefox has a MOZ_FALLTHROUGH macro that expands
> to [[clang::fallthrough]] for clang and just plain /*fall-through*/ for
> everything else.
>
> If we had support for something like that, and could rewrite all our
> current /*fall-through*/ and //FALL_THROUGH etc comments to that macro,
> then perhaps we could enable this warning by default and we wouldn't
> see as many of these missing breaks getting missed until the next
> coverity run as I've been seeing over the last few weeks.

Clang's -Wimplicit-fallthrough is quite old (at least available already 
back in Clang 3.2).  But not enabled with -Wall/-Wextra, so somehow 
always fell through the cracks of getting enabled for our code base.

C++17 will have a standard [[fallthrough]] annotation, but for now we 
can #ifdef some SAL_FALLTHROUGH as [[clang::fallthrough]], for 
LIBO_INTERNAL_ONLY at least, in sal/types.h.  Will take a look.

(IIRC, some static analysis tools use a heuristic of not warning about 
fall-through switches if there's any kind of comment directly before (or 
after?) the switch, but Clang's -Wimplicit-fallthrough needs an explicit 
[[fallthrough]]; annotation.)


More information about the LibreOffice mailing list