summaryrefslogtreecommitdiffstats
path: root/src/corelib/global/qcompilerdetection.h
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@theqtcompany.com>2016-06-27 15:43:33 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2016-08-19 18:38:53 +0000
commit9f888d2fde9c5413e5519e0914e9b13638760985 (patch)
tree7e211a2ae70c272ea8041d5100f0c9a67b32de1b /src/corelib/global/qcompilerdetection.h
parent25dd9c521fc064a71db63b110b7973225ee20c02 (diff)
Support C++17 fallthrough attribute
Replaces our mix of comments for annotating intended absence of break in switches with the C++17 attribute [[fallthrough]], or its earlier a clang extension counterpart. Change-Id: I4b2d0b9b5e4425819c7f1bf01608093c536b6d14 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/global/qcompilerdetection.h')
-rw-r--r--src/corelib/global/qcompilerdetection.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/corelib/global/qcompilerdetection.h b/src/corelib/global/qcompilerdetection.h
index 70c9e97c13..085e3063b4 100644
--- a/src/corelib/global/qcompilerdetection.h
+++ b/src/corelib/global/qcompilerdetection.h
@@ -1341,6 +1341,18 @@
Q_ASSUME_IMPL(valueOfExpression);\
} while (0)
+#if QT_HAS_CPP_ATTRIBUTE(fallthrough)
+# define Q_FALLTHROUGH() [[fallthrough]]
+#elif defined(__cplusplus)
+/* 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]]
+# endif
+#endif
+#ifndef Q_FALLTHROUGH
+# define Q_FALLTHROUGH() (void)0
+#endif
+
/*
Sanitize compiler feature availability