diff options
Diffstat (limited to 'src/corelib/global/qcompilerdetection.h')
-rw-r--r-- | src/corelib/global/qcompilerdetection.h | 85 |
1 files changed, 68 insertions, 17 deletions
diff --git a/src/corelib/global/qcompilerdetection.h b/src/corelib/global/qcompilerdetection.h index 5baa69270e..b2340bff8e 100644 --- a/src/corelib/global/qcompilerdetection.h +++ b/src/corelib/global/qcompilerdetection.h @@ -2,10 +2,6 @@ // Copyright (C) 2016 Intel Corporation. // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only -#ifndef QGLOBAL_H -# include <QtCore/qglobal.h> -#endif - #if 0 #pragma qt_class(QtCompilerDetection) #pragma qt_sync_skip_header_check @@ -16,6 +12,8 @@ #define QCOMPILERDETECTION_H #include <QtCore/qprocessordetection.h> +#include <QtCore/qsystemdetection.h> +#include <QtCore/qtconfiginclude.h> /* The compiler, must be one of: (Q_CC_x) @@ -77,8 +75,10 @@ # define Q_UNREACHABLE_IMPL() __assume(0) # define Q_DECL_EXPORT __declspec(dllexport) # define Q_DECL_IMPORT __declspec(dllimport) -# define QT_MAKE_UNCHECKED_ARRAY_ITERATOR(x) stdext::make_unchecked_array_iterator(x) // Since _MSC_VER >= 1800 -# define QT_MAKE_CHECKED_ARRAY_ITERATOR(x, N) stdext::make_checked_array_iterator(x, size_t(N)) // Since _MSC_VER >= 1500 +# if _MSC_VER < 1938 // stdext is deprecated since VS 2022 17.8 +# define QT_MAKE_CHECKED_ARRAY_ITERATOR(x, N) stdext::make_checked_array_iterator(x, size_t(N)) // Since _MSC_VER >= 1500 +# endif +# define Q_COMPILER_COMPLAINS_ABOUT_RETURN_AFTER_UNREACHABLE #elif defined(__BORLANDC__) || defined(__TURBOC__) # define Q_CC_BOR @@ -122,7 +122,11 @@ // define to verify the Clang version we hard-code the versions // based on the best available info we have about the actual // version: http://en.wikipedia.org/wiki/Xcode#Toolchain_Versions -# if __apple_build_version__ >= 13160021 // Xcode 13.3 +# if __apple_build_version__ >= 14030022 // Xcode 14.3 +# define Q_CC_CLANG 1500 +# elif __apple_build_version__ >= 14000029 // Xcode 14.0 +# define Q_CC_CLANG 1400 +# elif __apple_build_version__ >= 13160021 // Xcode 13.3 # define Q_CC_CLANG 1300 # elif __apple_build_version__ >= 13000029 // Xcode 13.0 # define Q_CC_CLANG 1200 @@ -846,6 +850,15 @@ # if _MSC_VER >= 1910 # define Q_COMPILER_CONSTEXPR # endif +// MSVC versions before 19.36 have a bug in C++20 comparison implementation. +// This leads to ambiguities when resolving comparison operator overloads in +// certain scenarios (the buggy MSVC versions were checked using our CI and +// compiler explorer). +# if _MSC_VER < 1936 +# define Q_COMPILER_LACKS_THREE_WAY_COMPARE_SYMMETRY +# endif +// QTBUG-124376: MSVC is slow at compiling qstrnlen() +# define Q_COMPILER_SLOW_QSTRNLEN_COMPILATION # endif /* __cplusplus */ #endif // defined(Q_CC_MSVC) && !defined(Q_CC_CLANG) @@ -891,16 +904,22 @@ # endif // !_HAS_CONSTEXPR # endif // !__GLIBCXX__ && !_LIBCPP_VERSION # endif // Q_OS_QNX -# if defined(Q_CC_CLANG) && defined(Q_OS_DARWIN) && defined(__GNUC_LIBSTD__) \ - && ((__GNUC_LIBSTD__-0) * 100 + __GNUC_LIBSTD_MINOR__-0 <= 402) +# if defined(Q_CC_CLANG) && defined(Q_OS_DARWIN) +# if defined(__GNUC_LIBSTD__) && ((__GNUC_LIBSTD__-0) * 100 + __GNUC_LIBSTD_MINOR__-0 <= 402) // Apple has not updated libstdc++ since 2007, which means it does not have // <initializer_list> or std::move. Let's disable these features -# undef Q_COMPILER_INITIALIZER_LISTS -# undef Q_COMPILER_RVALUE_REFS -# undef Q_COMPILER_REF_QUALIFIERS +# undef Q_COMPILER_INITIALIZER_LISTS +# undef Q_COMPILER_RVALUE_REFS +# undef Q_COMPILER_REF_QUALIFIERS // Also disable <atomic>, since it's clearly not there -# undef Q_COMPILER_ATOMICS -# endif +# undef Q_COMPILER_ATOMICS +# endif +# if defined(__cpp_lib_memory_resource) \ + && ((defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED < 140000) \ + || (defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED < 170000)) +# undef __cpp_lib_memory_resource // Only supported on macOS 14 and iOS 17 +# endif +# endif // defined(Q_CC_CLANG) && defined(Q_OS_DARWIN) #endif // Don't break code that is already using Q_COMPILER_DEFAULT_DELETE_MEMBERS @@ -946,6 +965,20 @@ # define Q_REQUIRED_RESULT [[nodiscard]] #endif +#if __has_cpp_attribute(nodiscard) >= 201907L /* used for both P1771 and P1301... */ +// [[nodiscard]] constructor (P1771) +# ifndef Q_NODISCARD_CTOR +# define Q_NODISCARD_CTOR [[nodiscard]] +# endif +// [[nodiscard("reason")]] (P1301) +# ifndef Q_NODISCARD_X +# define Q_NODISCARD_X(message) [[nodiscard(message)]] +# endif +# ifndef Q_NODISCARD_CTOR_X +# define Q_NODISCARD_CTOR_X(message) [[nodiscard(message)]] +# endif +#endif + #if __has_cpp_attribute(maybe_unused) # undef Q_DECL_UNUSED # define Q_DECL_UNUSED [[maybe_unused]] @@ -995,6 +1028,15 @@ #ifndef Q_REQUIRED_RESULT # define Q_REQUIRED_RESULT #endif +#ifndef Q_NODISCARD_X +# define Q_NODISCARD_X(message) Q_REQUIRED_RESULT +#endif +#ifndef Q_NODISCARD_CTOR +# define Q_NODISCARD_CTOR +#endif +#ifndef Q_NODISCARD_CTOR_X +# define Q_NODISCARD_CTOR_X(message) Q_NODISCARD_CTOR +#endif #ifndef Q_DECL_DEPRECATED # define Q_DECL_DEPRECATED #endif @@ -1181,11 +1223,11 @@ #endif #endif #ifndef Q_FALLTHROUGH -# if defined(Q_CC_GNU_ONLY) && Q_CC_GNU >= 700 +# ifdef Q_CC_GNU # define Q_FALLTHROUGH() __attribute__((fallthrough)) # else # define Q_FALLTHROUGH() (void)0 -#endif +# endif #endif @@ -1358,8 +1400,17 @@ QT_WARNING_DISABLE_MSVC(4530) /* C++ exception handler used, but unwind semantic # endif #endif -#if __cplusplus >= 202002L // P0846 doesn't have a feature macro :/ +// libstdc++ shipped with gcc < 11 does not have a fix for defect LWG 3346 +#if __cplusplus >= 202002L && (!defined(_GLIBCXX_RELEASE) || _GLIBCXX_RELEASE >= 11) +# define QT_COMPILER_HAS_LWG3346 +#endif + +#if defined(__cplusplus) && __cplusplus >= 202002L // P0846 doesn't have a feature macro :/ +# if !defined(Q_CC_MSVC_ONLY) || Q_CC_MSVC < 1939 // claims C++20 support but lacks P0846 + // 1939 is known to work + // 1936 is known to fail # define QT_COMPILER_HAS_P0846 +# endif #endif #ifdef QT_COMPILER_HAS_P0846 |