[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [sr #110032] For C++98 stack_symbol_type defines only non-const oper
From: |
Akim Demaille |
Subject: |
Re: [sr #110032] For C++98 stack_symbol_type defines only non-const operator= |
Date: |
Wed, 25 Sep 2019 21:46:41 +0200 |
Hi!
> Le 25 sept. 2019 à 18:38, anonymous <address@hidden> a écrit :
>
> URL:
> <https://savannah.gnu.org/support/?110032>
>
> Summary: For C++98 stack_symbol_type defines only non-const
> operator=
> Project: Bison
> Submitted by: None
> Submitted on: Wed 25 Sep 2019 04:38:56 PM UTC
> Category: None
> Priority: 5 - Normal
> Severity: 3 - Normal
> Status: None
> Privacy: Public
> Assigned to: None
> Originator Email: address@hidden
> Open/Closed: Open
> Discussion Lock: Any
> Operating System: None
For the record, what version of Bison was this? It's amazing that the bug
report form does not ask for such an information piece of information...
> Details:
>
> Setting the output language to C++ and compiling the output with a C++98
> compiler, compilation fails on the IAR C++ compiler (version 6.70.2.6274).
I have never heard of this compiler before. It does not seem possible to use
it in our CI, that's a pity. Have to tried to run Bison's test suite with this
C++ compiler? It would be nice to get the result, and in the future to have
someone agree to check betas of Bisons :)
> The std::vector class of the IAR compiler relies on operator= in its push_back
> implementation. Defining 'stack_symbol_type &operator=(stack_symbol_type &)'
> stops the compiler implicitly generating operator= for other arguments.
> Specifically 'const stack_symbol_type &operator=(const stack_symbol_type &) is
> missing which is needed by std::vector::push_back.
>
> The lalr1.cc skeleton needs to be changed to also define the const operator=
> for stack_symbol_type (and also others like sematic_type when using variants)
Doh.
That was introduced in
https://github.com/akimd/bison/commit/2116ad3a280f79ab28eba244a00d7d1358f141ef,
released in 3.2.4.
Could you please try this?
commit bdadd076ed2d8ef237965a607cd3112aa2cc1246
Author: Akim Demaille <address@hidden>
Date: Wed Sep 25 19:34:34 2019 +0200
WIP: add copy ctors
* #: .
diff --git a/data/skeletons/lalr1.cc b/data/skeletons/lalr1.cc
index d1c30403..cfca80b2 100644
--- a/data/skeletons/lalr1.cc
+++ b/data/skeletons/lalr1.cc
@@ -335,6 +335,9 @@ m4_define([b4_shared_declarations],
/// Assignment, needed by push_back by some old implementations.
/// Moves the contents of that.
stack_symbol_type& operator= (stack_symbol_type& that);
+
+ /// Assignment, needed by push_back by other implementations.
+ stack_symbol_type& operator= (const stack_symbol_type& that);
#endif
};
@@ -627,6 +630,17 @@ m4_if(b4_prefix, [yy], [],
}
#if YY_CPLUSPLUS < 201103L
+ ]b4_parser_class[::stack_symbol_type&
+ ]b4_parser_class[::stack_symbol_type::operator= (const stack_symbol_type&
that)
+ {
+ state = that.state;
+ ]b4_variant_if([b4_symbol_variant([that.type_get ()],
+ [value], [copy], [that.value])],
+ [[value = that.value;]])[]b4_locations_if([
+ location = that.location;])[
+ return *this;
+ }
+
]b4_parser_class[::stack_symbol_type&
]b4_parser_class[::stack_symbol_type::operator= (stack_symbol_type& that)
{
- Re: [sr #110032] For C++98 stack_symbol_type defines only non-const operator=,
Akim Demaille <=