mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-22 02:33:03 +00:00
lalr1.cc: don't generate useless constructors when variant is used
This generates less code, which is nicer to read, but also takes less chances with compilers such as G++ 4.8 that are too strict and check "dead code" (templated code that is not instantiated). * data/c++.m4 (b4_symbol_type_declare, b4_symbol_type_define): When variants are used, don't generate code meant for non variants.
This commit is contained in:
30
data/c++.m4
30
data/c++.m4
@@ -222,12 +222,12 @@ m4_define([b4_symbol_type_declare],
|
|||||||
]b4_type_foreach([b4_basic_symbol_constructor_declare])], [[
|
]b4_type_foreach([b4_basic_symbol_constructor_declare])], [[
|
||||||
/// Constructor for valueless symbols.
|
/// Constructor for valueless symbols.
|
||||||
basic_symbol (typename Base::kind_type t]b4_locations_if([,
|
basic_symbol (typename Base::kind_type t]b4_locations_if([,
|
||||||
const location_type& l])[);]])[
|
const location_type& l])[);
|
||||||
|
|
||||||
/// Constructor for symbols with semantic value.
|
/// Constructor for symbols with semantic value.
|
||||||
basic_symbol (typename Base::kind_type t,
|
basic_symbol (typename Base::kind_type t,
|
||||||
const semantic_type& v]b4_locations_if([,
|
const semantic_type& v]b4_locations_if([,
|
||||||
const location_type& l])[);
|
const location_type& l])[);]])[
|
||||||
|
|
||||||
/// Destroy the symbol.
|
/// Destroy the symbol.
|
||||||
~basic_symbol ();
|
~basic_symbol ();
|
||||||
@@ -317,18 +317,6 @@ m4_define([b4_public_types_define],
|
|||||||
[other.value])])[
|
[other.value])])[
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Base>
|
|
||||||
]b4_parser_class_name[::basic_symbol<Base>::basic_symbol (]b4_join(
|
|
||||||
[typename Base::kind_type t],
|
|
||||||
[const semantic_type& v],
|
|
||||||
b4_locations_if([const location_type& l]))[)
|
|
||||||
: Base (t)
|
|
||||||
, value (]b4_variant_if([], [v])[)]b4_locations_if([
|
|
||||||
, location (l)])[
|
|
||||||
{]b4_variant_if([[
|
|
||||||
(void) v;
|
|
||||||
]b4_symbol_variant([this->type_get ()], [value], [copy], [v])])[}
|
|
||||||
|
|
||||||
]b4_variant_if([[
|
]b4_variant_if([[
|
||||||
// Implementation of basic_symbol constructor for each type.
|
// Implementation of basic_symbol constructor for each type.
|
||||||
]b4_type_foreach([b4_basic_symbol_constructor_define])], [[
|
]b4_type_foreach([b4_basic_symbol_constructor_define])], [[
|
||||||
@@ -340,7 +328,19 @@ m4_define([b4_public_types_define],
|
|||||||
: Base (t)
|
: Base (t)
|
||||||
, value ()]b4_locations_if([
|
, value ()]b4_locations_if([
|
||||||
, location (l)])[
|
, location (l)])[
|
||||||
{}]])[
|
{}
|
||||||
|
|
||||||
|
template <typename Base>
|
||||||
|
]b4_parser_class_name[::basic_symbol<Base>::basic_symbol (]b4_join(
|
||||||
|
[typename Base::kind_type t],
|
||||||
|
[const semantic_type& v],
|
||||||
|
b4_locations_if([const location_type& l]))[)
|
||||||
|
: Base (t)
|
||||||
|
, value (]b4_variant_if([], [v])[)]b4_locations_if([
|
||||||
|
, location (l)])[
|
||||||
|
{]b4_variant_if([[
|
||||||
|
(void) v;
|
||||||
|
]b4_symbol_variant([this->type_get ()], [value], [copy], [v])])[}]])[
|
||||||
|
|
||||||
template <typename Base>
|
template <typename Base>
|
||||||
]b4_parser_class_name[::basic_symbol<Base>::~basic_symbol ()
|
]b4_parser_class_name[::basic_symbol<Base>::~basic_symbol ()
|
||||||
|
|||||||
Reference in New Issue
Block a user