diff options
author | Fabian Kosmale <fabian.kosmale@qt.io> | 2021-06-06 12:14:17 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2021-06-07 15:14:24 +0000 |
commit | 5f569ed01bc2aae9bdd6e8fa86e74b334d3eec1c (patch) | |
tree | 29636a686e1a343d631e8c39cc895b8d2aef466f /src | |
parent | 9c2660f6853eeec0847946e23c2258d98ac3d30d (diff) |
QProperty: Fix source_location feature testing
The presence of the source_location header does not guarantee the
availablility of std::source_location. For instance, if using clang 11
with a modern libstdc++, the source_location header is available, but
std::source_location is not available as it would require
__builtin_source_location, which clang does not implement.
Consequently, we need to explicitly check the feature test macro
instead, and only use std::(experimental::)source_location when it is
defined.
Task-number: QTBUG-94194
Change-Id: If6fda9a1b98244b1f2944fff6fe1991def30fc0f
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
(cherry picked from commit 1924f78df68d69fa7c69c394c547307e25dfffe1)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/corelib/kernel/qproperty.h | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/corelib/kernel/qproperty.h b/src/corelib/kernel/qproperty.h index 1cf06839df..0395b2840c 100644 --- a/src/corelib/kernel/qproperty.h +++ b/src/corelib/kernel/qproperty.h @@ -51,15 +51,23 @@ #if __has_include(<source_location>) && __cplusplus >= 202002L && !defined(Q_CLANG_QDOC) #include <source_location> +#if defined(__cpp_lib_source_location) #define QT_SOURCE_LOCATION_NAMESPACE std #define QT_PROPERTY_COLLECT_BINDING_LOCATION #define QT_PROPERTY_DEFAULT_BINDING_LOCATION QPropertyBindingSourceLocation(std::source_location::current()) -#elif __has_include(<experimental/source_location>) && __cplusplus >= 201703L && !defined(Q_CLANG_QDOC) +#endif +#endif + +#if !defined(QT_PROPERTY_COLLECT_BINDING_LOCATION) && __has_include(<experimental/source_location>) && __cplusplus >= 201703L && !defined(Q_CLANG_QDOC) #include <experimental/source_location> +#if defined(__cpp_lib_experimental_source_location) #define QT_SOURCE_LOCATION_NAMESPACE std::experimental #define QT_PROPERTY_COLLECT_BINDING_LOCATION #define QT_PROPERTY_DEFAULT_BINDING_LOCATION QPropertyBindingSourceLocation(std::experimental::source_location::current()) -#else +#endif +#endif + +#if !defined(QT_PROPERTY_COLLECT_BINDING_LOCATION) #define QT_PROPERTY_DEFAULT_BINDING_LOCATION QPropertyBindingSourceLocation() #endif |