diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2016-07-18 13:48:06 -0700 |
---|---|---|
committer | Thiago Macieira <thiago.macieira@intel.com> | 2016-08-09 02:41:19 +0000 |
commit | e24f89f266cee6e2473af6f66bd78f2df3a51c83 (patch) | |
tree | 0add769a4d2d0afd5b25300d90b002476a6531df /src/corelib | |
parent | 30eecdf6d8e593027542df8e809dc2b5f33cc60e (diff) |
Fix build with clang-cl and the Intel compiler on Windows
Neither clang-cl nor the Intel compiler are able to parse the MSVC code
in a constexpr environment. For Clang, we can just use the __builtin
functions, which it does make available on Windows. For the Intel
compiler, there's no alternative, so we just don't use the _BitScanXxx
functions. It will produce slower code, though.
qalgorithms.h(587,19) : error: variables defined in a constexpr function must be initialized
qalgorithms.h(635,12) : note: non-constexpr function '__popcnt' cannot be used in a constant expression
etc.
Change-Id: I149e0540c00745fe8119fffd14627ded43807000
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib')
-rw-r--r-- | src/corelib/tools/qalgorithms.h | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/corelib/tools/qalgorithms.h b/src/corelib/tools/qalgorithms.h index 6e68bc7eb1..6e472e8b22 100644 --- a/src/corelib/tools/qalgorithms.h +++ b/src/corelib/tools/qalgorithms.h @@ -516,14 +516,19 @@ QT_DEPRECATED_X("Use std::binary_search") Q_OUTOFLINE_TEMPLATE RandomAccessItera #endif // QT_DEPRECATED_SINCE(5, 2) +#ifdef Q_CC_CLANG // Clang had a bug where __builtin_ctz/clz/popcount were not marked as constexpr. -#if !defined Q_CC_CLANG || (defined __apple_build_version__ && __clang_major__ >= 7) \ - || (Q_CC_CLANG >= 307) +# if (defined __apple_build_version__ && __clang_major__ >= 7) || (Q_CC_CLANG >= 307) +# define QT_HAS_CONSTEXPR_BUILTINS +# endif +#elif defined(Q_CC_MSVC) && !defined(Q_CC_INTEL) && !defined(Q_OS_WINCE) && !defined(Q_PROCESSOR_ARM) +# define QT_HAS_CONSTEXPR_BUILTINS +#elif defined(Q_CC_GNU) # define QT_HAS_CONSTEXPR_BUILTINS #endif #if defined QT_HAS_CONSTEXPR_BUILTINS -#if defined(Q_CC_GNU) +#if defined(Q_CC_GNU) || defined(Q_CC_CLANG) # define QT_HAS_BUILTIN_CTZS Q_DECL_CONSTEXPR Q_ALWAYS_INLINE uint qt_builtin_ctzs(quint16 v) Q_DECL_NOTHROW { |