Add upstream patches for improved gcc 14 and C++20 support

This commit is contained in:
Tom Hughes 2024-01-18 16:01:07 +00:00
parent 844042b1f6
commit 34faab1e31
8 changed files with 203 additions and 17 deletions

View File

@ -0,0 +1,25 @@
From 1257fe9096b70cc278f9d6e4029776b50df5d5cf Mon Sep 17 00:00:00 2001
From: Janusz Chorko <janusz.chorko@apdu.pl>
Date: Fri, 26 Aug 2016 21:17:38 +0200
Subject: [PATCH 1/7] Removed non-compiling assignment operator. Fixed #718
---
include/rapidjson/document.h | 2 --
1 file changed, 2 deletions(-)
diff --git a/include/rapidjson/document.h b/include/rapidjson/document.h
index e3e20dfb..b0f1f70b 100644
--- a/include/rapidjson/document.h
+++ b/include/rapidjson/document.h
@@ -316,8 +316,6 @@ struct GenericStringRef {
GenericStringRef(const GenericStringRef& rhs) : s(rhs.s), length(rhs.length) {}
- GenericStringRef& operator=(const GenericStringRef& rhs) { s = rhs.s; length = rhs.length; }
-
//! implicit conversion to plain CharType pointer
operator const Ch *() const { return s; }
--
2.43.0

View File

@ -0,0 +1,25 @@
From f9d9e50caca4673f194115b059fe5daef77163fd Mon Sep 17 00:00:00 2001
From: Janusz Chorko <janusz.chorko@apdu.pl>
Date: Fri, 26 Aug 2016 21:26:50 +0200
Subject: [PATCH 2/7] Explicitly disable copy assignment operator
---
include/rapidjson/document.h | 2 ++
1 file changed, 2 insertions(+)
diff --git a/include/rapidjson/document.h b/include/rapidjson/document.h
index b0f1f70b..19f5a6a5 100644
--- a/include/rapidjson/document.h
+++ b/include/rapidjson/document.h
@@ -326,6 +326,8 @@ private:
//! Disallow construction from non-const array
template<SizeType N>
GenericStringRef(CharType (&str)[N]) /* = delete */;
+ //! Copy assignment operator not permitted - immutable type
+ GenericStringRef& operator=(const GenericStringRef& rhs) /* = delete */;
};
//! Mark a character pointer as constant string
--
2.43.0

View File

@ -1,16 +1,28 @@
commit c6c56d87ff12ba8100b261f371fdaa106f95fe14
Author: Tom Hughes <tom@compton.nu>
Date: Tue Sep 1 19:24:03 2020 +0100
From 2cecf24712bfe0f3d821a6f3763156066c7c40ec Mon Sep 17 00:00:00 2001
From: Nikolay <211292+kolya7k@users.noreply.github.com>
Date: Mon, 30 Mar 2020 07:20:35 +0500
Subject: [PATCH 3/7] Three-way comparison for CLang 10 fix (#1679)
Avoid ambiguous operator errors in C++20
Derived from upstream commit ebcbd04484fcdaddbb9fd7798e76bbfb4ae8f840
C++20 features must enable additional functionality, not to change interface completely
---
include/rapidjson/document.h | 19 +++++++++++++------
1 file changed, 13 insertions(+), 6 deletions(-)
diff --git a/include/rapidjson/document.h b/include/rapidjson/document.h
index e3e20dfb..1485321d 100644
index 19f5a6a5..8e13d1cc 100644
--- a/include/rapidjson/document.h
+++ b/include/rapidjson/document.h
@@ -168,12 +168,12 @@ public:
@@ -24,6 +24,9 @@
#include "encodedstream.h"
#include <new> // placement new
#include <limits>
+#ifdef __cpp_lib_three_way_comparison
+#include <compare>
+#endif
RAPIDJSON_DIAG_PUSH
#ifdef _MSC_VER
@@ -168,12 +171,16 @@ public:
//! @name relations
//@{
@ -26,6 +38,13 @@ index e3e20dfb..1485321d 100644
+ template <bool Const_> bool operator>=(const GenericMemberIterator<Const_, Encoding, Allocator>& that) const { return ptr_ >= that.ptr_; }
+ template <bool Const_> bool operator< (const GenericMemberIterator<Const_, Encoding, Allocator>& that) const { return ptr_ < that.ptr_; }
+ template <bool Const_> bool operator> (const GenericMemberIterator<Const_, Encoding, Allocator>& that) const { return ptr_ > that.ptr_; }
+
+#ifdef __cpp_lib_three_way_comparison
+ template <bool Const_> std::strong_ordering operator<=>(const GenericMemberIterator<Const_, Encoding, Allocator>& that) const { return ptr_ <=> that.ptr_; }
+#endif
//@}
//! @name dereference
--
2.43.0

View File

@ -0,0 +1,32 @@
From 11a7270fabf0c39cca0771453ae8a5df42d58f42 Mon Sep 17 00:00:00 2001
From: Laurent Stacul <laurent.stacul@amadeus.com>
Date: Mon, 22 Feb 2021 16:11:42 +0000
Subject: [PATCH 4/7] Fix recursive operator== call in C++20 (#1846)
---
include/rapidjson/document.h | 2 ++
1 file changed, 2 insertions(+)
diff --git a/include/rapidjson/document.h b/include/rapidjson/document.h
index 8e13d1cc..3c354a79 100644
--- a/include/rapidjson/document.h
+++ b/include/rapidjson/document.h
@@ -926,6 +926,7 @@ public:
*/
template <typename T> RAPIDJSON_DISABLEIF_RETURN((internal::IsGenericValue<T>), (bool)) operator!=(const T& rhs) const { return !(*this == rhs); }
+#ifndef __cpp_lib_three_way_comparison
//! Equal-to operator with arbitrary types (symmetric version)
/*! \return (rhs == lhs)
*/
@@ -936,6 +937,7 @@ public:
*/
template <typename T> friend RAPIDJSON_DISABLEIF_RETURN((internal::IsGenericValue<T>), (bool)) operator!=(const T& lhs, const GenericValue& rhs) { return !(rhs == lhs); }
//@}
+#endif
//!@name Type
//@{
--
2.43.0

View File

@ -0,0 +1,29 @@
From 424d1b95c7d95ac82f49bba82fdd05c29f73a2c1 Mon Sep 17 00:00:00 2001
From: Kent Ross <k@mad.cash>
Date: Mon, 14 Mar 2022 12:25:26 -0700
Subject: [PATCH 5/7] gate definition of symmetric equality operators on impl,
not lib
These operators call themselves recursively if C++20 semantics are present in the compiler, regardless of standard library support for the operator; therefore the test should be on __cpp_impl_three_way_comparison, not __cpp_lib_[...].
This fixes the Value.EqualtoOperator test when the language standard is set to C++20 and the standard library does not yet define the library support macro.
---
include/rapidjson/document.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/rapidjson/document.h b/include/rapidjson/document.h
index 3c354a79..46510f85 100644
--- a/include/rapidjson/document.h
+++ b/include/rapidjson/document.h
@@ -926,7 +926,7 @@ public:
*/
template <typename T> RAPIDJSON_DISABLEIF_RETURN((internal::IsGenericValue<T>), (bool)) operator!=(const T& rhs) const { return !(*this == rhs); }
-#ifndef __cpp_lib_three_way_comparison
+#ifndef __cpp_impl_three_way_comparison
//! Equal-to operator with arbitrary types (symmetric version)
/*! \return (rhs == lhs)
*/
--
2.43.0

View File

@ -0,0 +1,37 @@
From 42ca72bf3a161cf8d5e43f5d4f68aeeec3f7e6b4 Mon Sep 17 00:00:00 2001
From: Kent Ross <k@mad.cash>
Date: Thu, 3 Nov 2022 20:17:41 -0700
Subject: [PATCH 6/7] do not define operator!= in C++20
A change to the semantics of equality operator rewriting in C++20 (P2468R2: The Equality Operator You Are Looking For) means that operator== may not be rewritten with reversed operands if operator!= is also defined. Since operator!= can normally be synthesized from operator== regardless in this language standard, we can and should avoid defining those when the new language semantics are available.
This fixes the compilation of tests (and probably consuming code) in C++20 onwards for compilers that implement this new semantic, including recent nightly builds of clang-16.
Reference: https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p2468r2.html
---
include/rapidjson/document.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/rapidjson/document.h b/include/rapidjson/document.h
index 46510f85..8b0446db 100644
--- a/include/rapidjson/document.h
+++ b/include/rapidjson/document.h
@@ -912,6 +912,7 @@ public:
*/
template <typename T> RAPIDJSON_DISABLEIF_RETURN((internal::OrExpr<internal::IsPointer<T>,internal::IsGenericValue<T> >), (bool)) operator==(const T& rhs) const { return *this == GenericValue(rhs); }
+#ifndef __cpp_impl_three_way_comparison
//! Not-equal-to operator
/*! \return !(*this == rhs)
*/
@@ -926,7 +927,6 @@ public:
*/
template <typename T> RAPIDJSON_DISABLEIF_RETURN((internal::IsGenericValue<T>), (bool)) operator!=(const T& rhs) const { return !(*this == rhs); }
-#ifndef __cpp_impl_three_way_comparison
//! Equal-to operator with arbitrary types (symmetric version)
/*! \return (rhs == lhs)
*/
--
2.43.0

View File

@ -1,11 +1,14 @@
commit e61866f098098422462e8bc220506443e76c3bb0
Author: Björn Esser <me@besser82.io>
Date: Sun Apr 3 11:21:47 2016 +0200
From 486d1c6363e754bd30dfc24b345d9a9fe1737c92 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bj=C3=B6rn=20Esser?= <me@besser82.io>
Date: Sun, 3 Apr 2016 11:21:47 +0200
Subject: [PATCH 7/7] do not include gtest_src_dir
do not include gtest_src_dir
---
test/CMakeLists.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 11c1b04..43377db 100644
index 11c1b04c..43377dba 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -8,7 +8,7 @@ IF(GTESTSRC_FOUND)
@ -17,3 +20,6 @@ index 11c1b04..43377db 100644
include_directories(SYSTEM ${GTEST_INCLUDE_DIR})
set(TEST_LIBRARIES gtest gtest_main)
--
2.43.0

View File

@ -2,17 +2,27 @@
Name: rapidjson
Version: 1.1.0
Release: 24%{?dist}
Release: 25%{?dist}
Summary: Fast JSON parser and generator for C++
# Most files are MIT, rapidjson/msinttypes/{stdint,inttypes}.h are BSD
License: MIT AND BSD-3-Clause
URL: http://rapidjson.org/
Source0: https://github.com/Tencent/rapidjson/archive/v%{version}/%{name}-%{version}.tar.gz
# https://github.com/Tencent/rapidjson/pull/719
Patch: 0001-Removed-non-compiling-assignment-operator.-Fixed-718.patch
# https://github.com/Tencent/rapidjson/pull/719
Patch: 0002-Explicitly-disable-copy-assignment-operator.patch
# https://github.com/Tencent/rapidjson/pull/1137
Patch: 0003-Three-way-comparison-for-CLang-10-fix-1679.patch
# https://github.com/Tencent/rapidjson/pull/1679
Patch: 0004-Fix-recursive-operator-call-in-C-20-1846.patch
# https://github.com/Tencent/rapidjson/pull/1847
Patch: 0005-gate-definition-of-symmetric-equality-operators-on-i.patch
# https://github.com/Tencent/rapidjson/pull/2091
Patch: 0006-do-not-define-operator-in-C-20.patch
# Downstream-patch for gtest
Patch0: rapidjson-1.1.0-do_not_include_gtest_src_dir.patch
# Upstream derived patch for C++20 support
Patch1: rapidjson-1.1.0-c++20.patch
Patch: 0007-do-not-include-gtest_src_dir.patch
BuildRequires: cmake
BuildRequires: make
@ -120,6 +130,9 @@ find %{buildroot} -type f -name 'CMake*.txt' -delete
%changelog
* Thu Jan 18 2024 Tom Hughes <tom@compton.nu> - 1.1.0-25
- Add upstream patches for improved gcc 14 and C++20 support
* Fri Jan 05 2024 Honza Horak <hhorak@redhat.com> - 1.1.0-24
- SPDX migration
- Add BSD license that is used by stdint.h and inttypes.h