summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2016-10-07 10:38:42 +0200
committerMarc Mutz <marc.mutz@kdab.com>2016-10-10 17:17:54 +0000
commit7eddca359dd30d1dcfabb519f60ac4be83eda02c (patch)
tree16837a94ed395a84020ff5ab884bc7fc2f3ddebd /src/corelib
parent0a71cc111ae92cdae604fdb1d4ce0090f1fb6a20 (diff)
Q_FALLTHROUGH: use GCC extensions in non-C++17-code
GCC defines the [[gnu::fallthrough]] attribute for C++11 and C++14 code, as well as __attribute__((fallthrough)) for C++98 and C code. Use them. Change-Id: I66aa178c2a96e2ff9ac3f6f02821c978b4ec3696 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/global/qcompilerdetection.h8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/corelib/global/qcompilerdetection.h b/src/corelib/global/qcompilerdetection.h
index a3d816f0c3..dcdddeb04d 100644
--- a/src/corelib/global/qcompilerdetection.h
+++ b/src/corelib/global/qcompilerdetection.h
@@ -1351,10 +1351,16 @@
/* Clang can not parse namespaced attributes in C mode, but defines __has_cpp_attribute */
# if QT_HAS_CPP_ATTRIBUTE(clang::fallthrough)
# define Q_FALLTHROUGH() [[clang::fallthrough]]
+# elif QT_HAS_CPP_ATTRIBUTE(gnu::fallthrough)
+# define Q_FALLTHROUGH() [[gnu::fallthrough]]
# endif
#endif
#ifndef Q_FALLTHROUGH
-# define Q_FALLTHROUGH() (void)0
+# if defined(Q_CC_GNU) && Q_CC_GNU >= 700
+# define Q_FALLTHROUGH() __attribute__((fallthrough))
+# else
+# define Q_FALLTHROUGH() (void)0
+#endif
#endif