diff options
author | Zhang Xiang <gbcatmifu@hotmail.com> | 2021-04-22 15:35:29 +0800 |
---|---|---|
committer | Thiago Macieira <thiago.macieira@intel.com> | 2021-05-22 16:22:51 +0000 |
commit | 9433614df262be8aadfc764c855d4dd8fc0fb612 (patch) | |
tree | b8367e45f22f55c0879b0575a6d4db99bf5fd39f /tests/auto/corelib | |
parent | 5369a28df650c8f09e30dbf5c23746e103a87e7f (diff) |
Fix namespace error of std::source_location under C++20
With C++20 standard, src/corelib/kernel/qproperty.h of Qt Base cannot be
compiled at line 100:
QPropertyBindingSourceLocation(
const std::experimental::source_location &cppLocation
)
The reason is that source_location has been merged into namespace std
since C++20, and the header file has also been change from
<experimental/source_location> to <source_location>.
The problem can be avoided by define a constant.
Fixes: QTBUG-93270
Change-Id: I46b4daac6ea20f9623b43746880500d41396afb2
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
(cherry picked from commit 675a4b0cc77a81d92cea6e044200349676f3b117)
Diffstat (limited to 'tests/auto/corelib')
-rw-r--r-- | tests/auto/corelib/kernel/qproperty/tst_qproperty.cpp | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/tests/auto/corelib/kernel/qproperty/tst_qproperty.cpp b/tests/auto/corelib/kernel/qproperty/tst_qproperty.cpp index 6062c23189..4826e062d7 100644 --- a/tests/auto/corelib/kernel/qproperty/tst_qproperty.cpp +++ b/tests/auto/corelib/kernel/qproperty/tst_qproperty.cpp @@ -31,6 +31,14 @@ #include <qproperty.h> #include <private/qproperty_p.h> +#if __has_include(<source_location>) && __cplusplus >= 202002L && !defined(Q_CLANG_QDOC) +#include <source_location> +#define QT_SOURCE_LOCATION_NAMESPACE std +#elif __has_include(<experimental/source_location>) && __cplusplus >= 201703L && !defined(Q_CLANG_QDOC) +#include <experimental/source_location> +#define QT_SOURCE_LOCATION_NAMESPACE std::experimental +#endif + using namespace QtPrivate; @@ -434,7 +442,7 @@ void tst_QProperty::dontTriggerDependenciesIfUnchangedValue() void tst_QProperty::bindingSourceLocation() { #if defined(QT_PROPERTY_COLLECT_BINDING_LOCATION) - auto bindingLine = std::experimental::source_location::current().line() + 1; + auto bindingLine = QT_SOURCE_LOCATION_NAMESPACE::source_location::current().line() + 1; auto binding = Qt::makePropertyBinding([]() { return 42; }); QCOMPARE(QPropertyBindingPrivate::get(binding)->sourceLocation().line, bindingLine); #else @@ -1596,4 +1604,6 @@ void tst_QProperty::markDirty() QTEST_MAIN(tst_QProperty); +#undef QT_SOURCE_LOCATION_NAMESPACE + #include "tst_qproperty.moc" |