summaryrefslogtreecommitdiffstats
path: root/src/corelib/global/qcompilerdetection.h
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2012-06-13 15:23:12 +0200
committerQt by Nokia <qt-info@nokia.com>2012-06-29 00:27:18 +0200
commit4182a3afac5321b21496ae276446e3ba46d29fd4 (patch)
treeb3aa9256e472416e3c06c16389574947ad166b5d /src/corelib/global/qcompilerdetection.h
parent2b904294a87b303d4f1df03f92dd2c259ff53f00 (diff)
Add detection for C++11 noexcept
The Q_COMPILER_NOEXCEPT feature indicates whether this compiler has support for noexcept. Note that the GCC C++11 status page does not list this feature, but investigation into the source code as well as testing reveals it's supported since GCC 4.6. Also add Q_DECL_NOEXCEPT, to be used to declare that a function throws no exceptions, and Q_DECL_NOEXCEPT_EXPR(x), which declares that the function throws no exceptions if x evaluates to true. In C++98 mode, these macros expand to empty -- the old C++98 and C++03 exception specification is deprecated and considered harmful. Change-Id: Ic84901d13eceb06dcc7f025a4b7fc8b250769be9 Reviewed-by: Marc Mutz <marc.mutz@kdab.com> Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
Diffstat (limited to 'src/corelib/global/qcompilerdetection.h')
-rw-r--r--src/corelib/global/qcompilerdetection.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/corelib/global/qcompilerdetection.h b/src/corelib/global/qcompilerdetection.h
index 68c8f73fe3..6d8040a68f 100644
--- a/src/corelib/global/qcompilerdetection.h
+++ b/src/corelib/global/qcompilerdetection.h
@@ -451,6 +451,7 @@
* N2672 Q_COMPILER_INITIALIZER_LISTS
* N2658 N2927 Q_COMPILER_LAMBDA (v1.0 and above only)
* N2756 Q_COMPILER_NONSTATIC_MEMBER_INIT
+ * N2855 N3050 Q_COMPILER_NOEXCEPT
* N2431 Q_COMPILER_NULLPTR
* N2930 Q_COMPILER_RANGE_FOR
* N2442 Q_COMPILER_RAW_STRINGS
@@ -554,6 +555,9 @@
# if __has_feature(cxx_lambdas)
# define Q_COMPILER_LAMBDA
# endif
+# if __has_feature(cxx_noexcept)
+# define Q_COMPILER_NOEXCEPT
+# endif
# if __has_feature(cxx_nonstatic_member_init)
# define Q_COMPILER_NONSTATIC_MEMBER_INIT
# endif
@@ -631,6 +635,7 @@
# if (__GNUC__ * 100 + __GNUC_MINOR__) >= 406
/* C++11 features supported in GCC 4.6: */
# define Q_COMPILER_CONSTEXPR
+# define Q_COMPILER_NOEXCEPT
# define Q_COMPILER_NULLPTR
# define Q_COMPILER_UNRESTRICTED_UNIONS
# define Q_COMPILER_RANGE_FOR
@@ -702,6 +707,14 @@
# define Q_DECL_FINAL_CLASS
#endif
+#ifdef Q_COMPILER_NOEXCEPT
+# define Q_DECL_NOEXCEPT noexcept
+# define Q_DECL_NOEXCEPT_EXPR(x) noexcept(x)
+#else
+# define Q_DECL_NOEXCEPT
+# define Q_DECL_NOEXCEPT_EXPR(x)
+#endif
+
#if defined(Q_COMPILER_ALIGNOF) && !defined(Q_ALIGNOF)
# define Q_ALIGNOF(x) alignof(x)
#endif