From be5dc0b90db68df57925ee951ccc480fcab14192 Mon Sep 17 00:00:00 2001 From: Rahul Singh Date: Wed, 20 Jan 2021 14:52:41 +0000 Subject: [PATCH] xen/compiler: import 'fallthrough' keyword from linux -Wimplicit-fallthrough warns when a switch case falls through. Warning can be suppress by either adding a /* fallthrough */ comment, or by using a null statement: __attribute__ ((fallthrough)) Define the pseudo keyword 'fallthrough' for the ability to convert the various case block /* fallthrough */ style comments to null statement "__attribute__((__fallthrough__))" 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: Rahul Singh Reviewed-by: Stefano Stabellini Reviewed-by: Bertrand Marquis --- xen/include/xen/compiler.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/xen/include/xen/compiler.h b/xen/include/xen/compiler.h index e643e69128..0ec0b4698e 100644 --- a/xen/include/xen/compiler.h +++ b/xen/include/xen/compiler.h @@ -33,6 +33,22 @@ #define unreachable() __builtin_unreachable() #endif +/* + * Add the pseudo keyword 'fallthrough' so case statement blocks + * must end with any of these keywords: + * break; + * fallthrough; + * goto