diff options
author | R.J.V. Bertin <rjvbertin@gmail.com> | 2017-05-31 12:04:18 +0200 |
---|---|---|
committer | René J.V. Bertin <rjvbertin@gmail.com> | 2017-06-05 07:20:55 +0000 |
commit | e8d391f1f409b1fe87cf117e16f3d3cc65ef3305 (patch) | |
tree | bb0061a810b83c1c518d82a0bcb8b7ebc5a93974 | |
parent | 1131db8b4708dfa222b50fb4981a7becaf5ae4a3 (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.
Task-number: QTBUG-61034
Change-Id: I8205793c1501a4243b14d8642fe1f16d2df69be4
(cherry picked from commit 6e97d091e4d30566c14cf726f44d9e17f819c2c2)
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
-rw-r--r-- | src/corelib/global/qcompilerdetection.h | 10 | ||||
-rw-r--r-- | src/corelib/global/qglobal.h | 7 |
2 files changed, 16 insertions, 1 deletions
diff --git a/src/corelib/global/qcompilerdetection.h b/src/corelib/global/qcompilerdetection.h index c8f1280e21..038ad03cb0 100644 --- a/src/corelib/global/qcompilerdetection.h +++ b/src/corelib/global/qcompilerdetection.h @@ -1155,6 +1155,16 @@ #endif /* + * a useful extension from Clang + * http://clang.llvm.org/docs/LanguageExtensions.html#feature-checking-macros + */ +#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 a7183cb983..4528005177 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 |