#3 Fix runtime support for C++20 mode (#1834782)
Merged 4 years ago by jjames. Opened 4 years ago by avik.
rpms/ avik/antlr3 c++20-fix  into  master

@@ -0,0 +1,39 @@ 

+ From 478902a7e57e2283c57410f5aa14939e743b5102 Mon Sep 17 00:00:00 2001

+ From: Avi Kivity <avi@scylladb.com>

+ Date: Tue, 12 May 2020 14:51:18 +0300

+ Subject: [PATCH] antlr3memory.hpp: fix for C++20 mode

+ 

+ gcc 10 in C++20 mode requires that the allocator type match

+ the type used to allocate, so do that by adding "const" to the

+ key type.

+ ---

+  runtime/Cpp/include/antlr3memory.hpp | 4 ++--

+  1 file changed, 2 insertions(+), 2 deletions(-)

+ 

+ diff --git a/runtime/Cpp/include/antlr3memory.hpp b/runtime/Cpp/include/antlr3memory.hpp

+ index 7713613..4667a00 100755

+ --- a/runtime/Cpp/include/antlr3memory.hpp

+ +++ b/runtime/Cpp/include/antlr3memory.hpp

+ @@ -98,17 +98,17 @@ public:

+  	{

+  	};

+  

+  	template<class KeyType, class ValueType>

+  	class UnOrderedMapType : public std::map< KeyType, ValueType, std::less<KeyType>, 

+ -										AllocatorType<std::pair<KeyType, ValueType> > >

+ +										AllocatorType<std::pair<const KeyType, ValueType> > >

+  	{

+  	};

+  

+  	template<class KeyType, class ValueType>

+  	class OrderedMapType : public std::map< KeyType, ValueType, std::less<KeyType>, 

+ -										AllocatorType<std::pair<KeyType, ValueType> > >

+ +										AllocatorType<std::pair<const KeyType, ValueType> > >

+  	{

+  	};

+  

+  	ANTLR_INLINE static void* operator new (std::size_t bytes)

+  	{ 

+ -- 

+ 2.26.2

+ 

file modified
+7 -1
@@ -1,7 +1,7 @@ 

  %global antlr_version 3.5.2

  %global c_runtime_version 3.4

  %global javascript_runtime_version 3.1

- %global baserelease 26

+ %global baserelease 27

  

  Summary:            ANother Tool for Language Recognition

  Name:               antlr3
@@ -27,6 +27,8 @@ 

  Patch4:         0004-eof-token.patch

  # Make parsers reproducible.  Patch from Debian.

  Patch5:         0005-reproducible-parsers.patch

+ # Fix for C++20

+ Patch6:         0006-antlr3memory.hpp-fix-for-C-20-mode.patch

  

  BuildRequires:  ant

  BuildRequires:  maven-local
@@ -143,6 +145,7 @@ 

  %patch3 -p1

  %patch4 -p1

  %patch5 -p1

+ %patch6 -p1

  

  # remove pre-built artifacts

  find -type f -a -name *.jar -delete
@@ -278,6 +281,9 @@ 

  %doc tool/LICENSE.txt

  

  %changelog

+ * Tue May 12 2020 Avi Kivity <avi@scylladb.com> - 1:3.5.2-27

+ - Fix for C++20 mode (#1834782)

+ 

  * Sat Apr 25 2020 Fabio Valentini <decathorpe@gmail.com> - 1:3.5.2-26

  - Remove unnecessary dependency on deprecated parent pom.

  

Added a patch that fixes the type used for std::allocator.

Note: please backport to f32.

This change is correct. It was never valid C++ to use an allocator with the wrong type, it was accepted as a non-standard GCC extension. C++20 now requires a diagnostic, so the GCC extension is disabled in C++20 mode.

Pull-Request has been merged by jjames

4 years ago

Thank you for the patch, Avi!