From e8d391f1f409b1fe87cf117e16f3d3cc65ef3305 Mon Sep 17 00:00:00 2001 From: "R.J.V. Bertin" Date: Wed, 31 May 2017 12:04:18 +0200 Subject: 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 --- src/corelib/global/qcompilerdetection.h | 10 ++++++++++ src/corelib/global/qglobal.h | 7 ++++++- 2 files changed, 16 insertions(+), 1 deletion(-) 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 @@ -1154,6 +1154,16 @@ # define QT_MAKE_CHECKED_ARRAY_ITERATOR(x, N) (x) #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 -- cgit v1.2.3