[cfe-commits] [PATCH] Fixes for unintended fall-through bugs (-Wimplicit-fallthrough)

Sebastian Redl sebastian.redl at getdesigned.at
Sun May 27 06:14:02 PDT 2012


On 27.05.2012, at 13:55, Matthieu Monrocq wrote:

> 
> 
> On Sun, May 27, 2012 at 12:30 AM, Alexander Kornienko <alexfh at google.com> wrote:
> 
> P.S. It would also be interesting to know what people think about converting fall-through annotations in comments to a checked annotation so we could use this diagnostic on regular basis?
> We could wrap [[clang::fallthrough]] to a macro, so the code would continue to work in c++98 mode, but in c++11 mode it would also allow to run this diagnostic (btw, is llvm compilable in c++11 mode?). Sample implementation of macro:
> #ifdef __clang__
> #if __has_feature(cxx_attributes) && __has_warning("-Wimplicit-fallthrough")
> #define FALLTHROUGH [[clang::fallthrough]]
> #endif
> #endif
> 
> #ifndef FALLTHROUGH
> #define FALLTHROUGH do { } while (0)
> #endif
> 
> -- 
> Best regards,
> Alexander Kornienko
> 
>  
> One question: in the proposed macro, why not put the the `;` in the macro since it will be mandatory anyway ?

I know several text editors whose simple indentation algorithm gets confused by lines not ending in semicolons. I prefer them outside the macro.

Sebastian
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120527/edf580d4/attachment.html>


More information about the cfe-commits mailing list