From bd9759bb238794af03ebfbc9b140ce82f18bd6c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Vr=C3=A1til?= Date: Tue, 4 May 2021 13:19:00 +0200 Subject: [PATCH] Add upstream patch to fix building against Qt6 with C++20 enabled --- qt6-qtbase.spec | 3 ++ qtbase-c++20.patch | 68 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+) create mode 100644 qtbase-c++20.patch diff --git a/qt6-qtbase.spec b/qt6-qtbase.spec index 048c134..5ed983a 100644 --- a/qt6-qtbase.spec +++ b/qt6-qtbase.spec @@ -101,6 +101,9 @@ Patch90: qtbase-gcc11.patch ## upstream patches +# allow building against Qt with C++20 enabled (QTBUG-93270) +Patch100: qtbase-c++20.patch + # Do not check any files in %%{_qt6_plugindir}/platformthemes/ for requires. # Those themes are there for platform integration. If the required libraries are # not there, the platform to integrate with isn't either. Then Qt will just diff --git a/qtbase-c++20.patch b/qtbase-c++20.patch new file mode 100644 index 0000000..244efb6 --- /dev/null +++ b/qtbase-c++20.patch @@ -0,0 +1,68 @@ +From 675a4b0cc77a81d92cea6e044200349676f3b117 Mon Sep 17 00:00:00 2001 +From: Zhang Xiang +Date: Thu, 22 Apr 2021 15:35:29 +0800 +Subject: 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 + to . + +The problem can be avoided by define a constant. + +Fixes: QTBUG-93270 +Change-Id: I46b4daac6ea20f9623b43746880500d41396afb2 +Reviewed-by: Thiago Macieira +Reviewed-by: Fabian Kosmale +--- + src/corelib/kernel/qproperty.h | 8 ++++++-- + 1 file changed, 6 insertions(+), 2 deletions(-) + +(limited to 'src/corelib/kernel/qproperty.h') + +diff --git a/src/corelib/kernel/qproperty.h b/src/corelib/kernel/qproperty.h +index 108f041d4f..9f15a2de7d 100644 +--- a/src/corelib/kernel/qproperty.h ++++ b/src/corelib/kernel/qproperty.h +@@ -50,11 +50,13 @@ + #include + + #if __has_include() && __cplusplus >= 202002L && !defined(Q_CLANG_QDOC) +-#include ++#include ++#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() && __cplusplus >= 201703L && !defined(Q_CLANG_QDOC) + #include ++#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 +@@ -102,7 +104,7 @@ struct Q_CORE_EXPORT QPropertyBindingSourceLocation + quint32 column = 0; + QPropertyBindingSourceLocation() = default; + #ifdef QT_PROPERTY_COLLECT_BINDING_LOCATION +- QPropertyBindingSourceLocation(const std::experimental::source_location &cppLocation) ++ QPropertyBindingSourceLocation(const QT_SOURCE_LOCATION_NAMESPACE::source_location &cppLocation) + { + fileName = cppLocation.file_name(); + functionName = cppLocation.function_name(); +@@ -1199,6 +1201,8 @@ public: + } \ + QObjectComputedProperty name; + ++#undef QT_SOURCE_LOCATION_NAMESPACE ++ + QT_END_NAMESPACE + + #endif // QPROPERTY_H +-- +cgit v1.2.1 +