On Wed, Jul 13, 2016 at 08:39:28PM +0200, Marc Glisse wrote: > On Wed, 13 Jul 2016, Marek Polacek wrote: > > > Does "__attribute__((fallthrough));" have any advantages over > > "__builtin_fallthrough()"? > > Not a strong argument, but compilers that don't know the construct will give > an error on the builtin, and just a warning on the attribute (and ignore the > comment, which makes both other versions less relevant). Hmm, I'd expect that people add something like
#if GCC_VERSION >= 7000 # define gcc_fallthrough() __builtin_fallthrough () #else # define gcc_fallthrough() #endif and not use the builtin directly. > Unrelated question: are there cases where __builtin_fallthrough() has any > impact on code generation? It should not -- my implementation gets rid of all __builtin_fallthrough() during gimple-low, before most of the optimizations kick in, so it shouldn't make any real difference. Marek