[glib/wip/baedert/fallthrough-clang] macros: Define G_GNUC_FALLTHROUGH for more compilers



commit 5f38ae5ffca3213addc5b279a46d537792d031db
Author: Timm Bäder <mail baedert org>
Date:   Fri Feb 28 08:59:23 2020 +0100

    macros: Define G_GNUC_FALLTHROUGH for more compilers
    
    Some compilers have __GNUC__ defined as a value less than 6, but do
    support implicit-fallthrough via __attribute__((fallthrough)). Define
    G_GNUC_FALLTHROUGH for those that support __has_attribute.

 glib/gmacros.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
---
diff --git a/glib/gmacros.h b/glib/gmacros.h
index 1f4d779be..fb14aa81a 100644
--- a/glib/gmacros.h
+++ b/glib/gmacros.h
@@ -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__ */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]