summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorR.J.V. Bertin <rjvbertin@gmail.com>2017-06-01 23:59:55 +0200
committerRené J.V. Bertin <rjvbertin@gmail.com>2017-06-03 07:22:06 +0000
commit6e97d091e4d30566c14cf726f44d9e17f819c2c2 (patch)
tree6005d4f3f1a89c57091b4e99827f1201fd14b5e7
parentb7d76e533c76f7d9e9373d68f33ff9595fe8ce52 (diff)
define QT_NO_EXCEPTIONS reliably when using Clang
Clang's definition of the __EXCEPTIONS macro is inconsistent across platforms. When compiling for Darwin, Clang 3.6 and newer will set the token when exceptions are enabled in either C++ or ObjC. This change adds the reliable check described in the Clang 3.6 release notes to ensure that QT_NO_EXCEPTIONS is defined when required. The check requires the use of the Clang-specific __has_feature() syntax for which a new proxy macro QT_HAS_FEATURE(x) is added in qcompilerdetection.h Task-number: QTBUG-61034 Change-Id: Ie7b482dfa1a4a5b700a6b97562c26b626be1fc04 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
-rw-r--r--src/corelib/global/qcompilerdetection.h5
-rw-r--r--src/corelib/global/qglobal.h7
2 files changed, 11 insertions, 1 deletions
diff --git a/src/corelib/global/qcompilerdetection.h b/src/corelib/global/qcompilerdetection.h
index 173ada89de..c221115e8f 100644
--- a/src/corelib/global/qcompilerdetection.h
+++ b/src/corelib/global/qcompilerdetection.h
@@ -1246,6 +1246,11 @@
#else
# define QT_HAS_INCLUDE_NEXT(x) 0
#endif
+#ifdef __has_feature
+# define QT_HAS_FEATURE(x) __has_feature(x)
+#else
+# define QT_HAS_FEATURE(x) 0
+#endif
/*
* Warning/diagnostic handling
diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h
index 79053329a1..f2f28343c6 100644
--- a/src/corelib/global/qglobal.h
+++ b/src/corelib/global/qglobal.h
@@ -631,7 +631,12 @@ inline void qt_noop(void) {}
*/
#if !defined(QT_NO_EXCEPTIONS)
-# if defined(QT_BOOTSTRAPPED) || (defined(Q_CC_GNU) && !defined (__EXCEPTIONS) && !defined(Q_MOC_RUN))
+# if !defined(Q_MOC_RUN)
+# if (defined(Q_CC_CLANG) && !defined(Q_CC_INTEL) && !QT_HAS_FEATURE(cxx_exceptions)) || \
+ (defined(Q_CC_GNU) && !defined(__EXCEPTIONS))
+# define QT_NO_EXCEPTIONS
+# endif
+# elif defined(QT_BOOTSTRAPPED)
# define QT_NO_EXCEPTIONS
# endif
#endif