This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Implement -Wswitch-fallthrough


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]