summaryrefslogtreecommitdiffstats
path: root/src/corelib/global
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2016-07-18 16:34:22 -0700
committerThiago Macieira <thiago.macieira@intel.com>2016-07-22 01:01:48 +0000
commitb5153d5bfab63da811b7a4615238d9e50198b412 (patch)
treef8279d191d775cc1b2c578079563097ab9b89e9f /src/corelib/global
parent8e4c8be0b9821ee2f3dbdda3ebbe16126d334959 (diff)
Windows: Disable unsupported C++11 features with Clang-cl and ICC
Whenever someone installs Clang or the Intel compiler on Windows, it's very likely that the compiler will be much newer than the MS headers that came with the installed Visual Studio version. So let's make sure we disable the C++11 features that the MS headers don't support properly. For example, MS's <limits> header supplied with VS 2013 doesn't mark the max() function as constexpr, resulting compiler errors in uses of that function in Qt code declared with Q_DECL_CONSTEXPR: qdeadlinetimer.h(62,13) : note: non-constexpr function 'max' cannot be used in a constant expression : s(std::numeric_limits<qint64>::max()), ns(0), type(type_) {} ^ Change-Id: I149e0540c00745fe8119fffd146286ffe480d216 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/global')
-rw-r--r--src/corelib/global/qcompilerdetection.h27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/corelib/global/qcompilerdetection.h b/src/corelib/global/qcompilerdetection.h
index 33e42a944d..e152786d3f 100644
--- a/src/corelib/global/qcompilerdetection.h
+++ b/src/corelib/global/qcompilerdetection.h
@@ -1031,6 +1031,33 @@
// critical definitions. (Reported as Intel Issue ID 6000117277)
# define __USE_CONSTEXPR 1
# define __USE_NOEXCEPT 1
+# elif defined(Q_CC_MSVC) && (defined(Q_CC_CLANG) || defined(Q_CC_INTEL))
+// Clang and the Intel compiler support more C++ features than the Microsoft compiler
+// so make sure we don't enable them if the MS headers aren't properly adapted.
+# ifndef _HAS_CONSTEXPR
+# undef Q_COMPILER_CONSTEXPR
+# endif
+# ifndef _HAS_DECLTYPE
+# undef Q_COMPILER_DECLTYPE
+# endif
+# ifndef _HAS_INITIALIZER_LISTS
+# undef Q_COMPILER_INITIALIZER_LISTS
+# endif
+# ifndef _HAS_NULLPTR_T
+# undef Q_COMPILER_NULLPTR
+# endif
+# ifndef _HAS_RVALUE_REFERENCES
+# undef Q_COMPILER_RVALUE_REFS
+# endif
+# ifndef _HAS_SCOPED_ENUM
+# undef Q_COMPILER_CLASS_ENUM
+# endif
+# ifndef _HAS_TEMPLATE_ALIAS
+# undef Q_COMPILER_TEMPLATE_ALIAS
+# endif
+# ifndef _HAS_VARIADIC_TEMPLATES
+# undef Q_COMPILER_VARIADIC_TEMPLATES
+# endif
# elif defined(_LIBCPP_VERSION)
// libc++ uses __has_feature(cxx_atomic), so disable the feature if the compiler
// doesn't support it. That's required for the Intel compiler 14.x or earlier on OS X, for example.