On Wed, 13 Jul 2016, Marek Polacek wrote:
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.
I expect people will mostly use the comment, or maybe the C++17 attribute
in a few years in C++ code. But accidents happen. I did say it was a weak
argument ;-)
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.
"should", "most", "real"... This is a bit like compare-debug, as a user I
expect it to only affect warnings, and if it can affect code generation,
even in small ways, I would like the doc to tell me.
--
Marc Glisse