mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-20 17:53:02 +00:00
c++: fix GCC8 warnings about uninitialized values
In 0931d14728 I removed too many
initializations from some ctors: some were not about base ctors, but
about member variables. In fact, more of them were missing to please
GCC 8.
While at it, generate more natural code for C++ without variant:
instead of
template <typename Base>
parser::basic_symbol<Base>::basic_symbol (const basic_symbol& other)
: Base (other)
, value ()
{
value = other.value
}
generate
template <typename Base>
parser::basic_symbol<Base>::basic_symbol (const basic_symbol& other)
: Base (other)
, value (other.value)
{}
* data/c++.m4 (basic_symbol::basic_symbol): Always initialize 'value',
it might be a POD without a ctor.
* data/lalr1.cc (stack_symbol_type::stack_symbol_type): Likewise.
* data/variant.hh (variant::variant): Default initialize the buffer too.
This commit is contained in:
18
data/c++.m4
18
data/c++.m4
@@ -296,18 +296,19 @@ m4_define([b4_public_types_define],
|
|||||||
|
|
||||||
// basic_symbol.
|
// basic_symbol.
|
||||||
template <typename Base>
|
template <typename Base>
|
||||||
]b4_parser_class_name[::basic_symbol<Base>::basic_symbol ()]b4_locations_if([
|
]b4_parser_class_name[::basic_symbol<Base>::basic_symbol ()
|
||||||
: location ()])[
|
: value ()]b4_locations_if([
|
||||||
|
, location ()])[
|
||||||
{}
|
{}
|
||||||
|
|
||||||
template <typename Base>
|
template <typename Base>
|
||||||
]b4_parser_class_name[::basic_symbol<Base>::basic_symbol (const basic_symbol& other)
|
]b4_parser_class_name[::basic_symbol<Base>::basic_symbol (const basic_symbol& other)
|
||||||
: Base (other)]b4_locations_if([
|
: Base (other)
|
||||||
|
, value (]b4_variant_if([], [other.value])[)]b4_locations_if([
|
||||||
, location (other.location)])[
|
, location (other.location)])[
|
||||||
{
|
{]b4_variant_if([
|
||||||
]b4_variant_if([b4_symbol_variant([other.type_get ()], [value], [copy],
|
b4_symbol_variant([other.type_get ()], [value], [copy],
|
||||||
[other.value])],
|
[other.value])])[
|
||||||
[value = other.value;])[
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Base>
|
template <typename Base>
|
||||||
@@ -330,7 +331,8 @@ m4_define([b4_public_types_define],
|
|||||||
]b4_parser_class_name[::basic_symbol<Base>::basic_symbol (]b4_join(
|
]b4_parser_class_name[::basic_symbol<Base>::basic_symbol (]b4_join(
|
||||||
[typename Base::kind_type t],
|
[typename Base::kind_type t],
|
||||||
b4_locations_if([const location_type& l]))[)
|
b4_locations_if([const location_type& l]))[)
|
||||||
: Base (t)]b4_locations_if([
|
: Base (t)
|
||||||
|
, value ()]b4_locations_if([
|
||||||
, location (l)])[
|
, location (l)])[
|
||||||
{}]])[
|
{}]])[
|
||||||
|
|
||||||
|
|||||||
@@ -574,11 +574,10 @@ m4_if(b4_prefix, [yy], [],
|
|||||||
{}
|
{}
|
||||||
|
|
||||||
]b4_parser_class_name[::stack_symbol_type::stack_symbol_type (state_type s, symbol_type& that)
|
]b4_parser_class_name[::stack_symbol_type::stack_symbol_type (state_type s, symbol_type& that)
|
||||||
: super_type (s]b4_locations_if([, that.location])[)
|
: super_type (s]b4_variant_if([], [, that.value])[]b4_locations_if([, that.location])[)
|
||||||
{
|
{]b4_variant_if([
|
||||||
]b4_variant_if([b4_symbol_variant([that.type_get ()],
|
b4_symbol_variant([that.type_get ()],
|
||||||
[value], [move], [that.value])],
|
[value], [move], [that.value])])[
|
||||||
[[value = that.value;]])[
|
|
||||||
// that is emptied.
|
// that is emptied.
|
||||||
that.type = empty_symbol;
|
that.type = empty_symbol;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -94,8 +94,9 @@ m4_define([b4_variant_define],
|
|||||||
typedef variant<S> self_type;
|
typedef variant<S> self_type;
|
||||||
|
|
||||||
/// Empty construction.
|
/// Empty construction.
|
||||||
variant ()]b4_parse_assert_if([
|
variant ()
|
||||||
: yytypeid_ (YY_NULLPTR)])[
|
: yybuffer_ ()]b4_parse_assert_if([
|
||||||
|
, yytypeid_ (YY_NULLPTR)])[
|
||||||
{}
|
{}
|
||||||
|
|
||||||
/// Construct and fill.
|
/// Construct and fill.
|
||||||
|
|||||||
Reference in New Issue
Block a user