Merge branch 'wip/baedert/fallthrough-clang' into 'master'

macros: Define G_GNUC_FALLTHROUGH for more compilers

See merge request GNOME/glib!1396
This commit is contained in:
Philip Withnall 2020-03-04 11:08:26 +00:00
commit 51953dd857

View File

@ -532,7 +532,7 @@
/**
* G_GNUC_FALLTHROUGH:
*
* Expands to the GNU C `fallthrough` statement attribute if the compiler is gcc.
* Expands to the GNU C `fallthrough` statement attribute if the compiler supports it.
* This allows declaring case statement to explicitly fall through in switch
* statements. To enable this feature, use `-Wimplicit-fallthrough` during
* compilation.
@ -559,6 +559,8 @@
*/
#if __GNUC__ > 6
#define G_GNUC_FALLTHROUGH __attribute__((fallthrough))
#elif g_macro__has_attribute (fallthrough)
#define G_GNUC_FALLTHROUGH __attribute__((fallthrough))
#else
#define G_GNUC_FALLTHROUGH
#endif /* __GNUC__ */