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

Alexander Kornienko alexfh at google.com
Mon May 28 17:38:09 PDT 2012


On Sun, May 27, 2012 at 1:55 PM, Matthieu Monrocq <
matthieu.monrocq at gmail.com> wrote:

> One question: in the proposed macro, why not put the the `;` in the macro
> since it will be mandatory anyway ?
 Keeping semicolon out of macro is intentional. That way macro usage looks
like a statement (which it is).

Also, it might be easier to just do:
> #if defined(__has_feature) and __has_feature(cxx_attributes)
> #  define FALLTHROUGH [[clang::fallthrough]];
> #else
> #  define FALLTHROUGH while(0) {}
> #endif
Unfortunately, it will not work at least on gcc, because it tries to parse
the whole #if condition at once and emits an error on __has_feature(...).

Best regards,
Alexander Kornienko
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120529/61d5a402/attachment.html>

More information about the cfe-commits mailing list