]> git.baikalelectronics.ru Git - kernel.git/commit
compiler_attributes.h: Add 'fallthrough' pseudo keyword for switch/case use
authorJoe Perches <joe@perches.com>
Sat, 5 Oct 2019 16:46:42 +0000 (09:46 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 11 Oct 2019 16:26:05 +0000 (09:26 -0700)
commit7e03d624784453b9164adfc7394ad14025b8eb26
tree8138e829d29b3f06e3bc1de49cab4a34e31dc1a7
parent370dbbc7ca5064fcc2598b3a3ba137530c5d0566
compiler_attributes.h: Add 'fallthrough' pseudo keyword for switch/case use

Reserve the pseudo keyword 'fallthrough' for the ability to convert the
various case block /* fallthrough */ style comments to appear to be an
actual reserved word with the same gcc case block missing fallthrough
warning capability.

All switch/case blocks now should end in one of:

break;
fallthrough;
goto <label>;
return [expression];
continue;

In C mode, GCC supports the __fallthrough__ attribute since 7.1,
the same time the warning and the comment parsing were introduced.

fallthrough devolves to an empty "do {} while (0)" if the compiler
version (any version less than gcc 7) does not support the attribute.

Signed-off-by: Joe Perches <joe@perches.com>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Suggested-by: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
include/linux/compiler_attributes.h