The diff below is somewhat hard to read: what happened is that some code which was outside the b4_variant_if was moved in its ‘else’ part. It should have been there from the start. Weirdly enough, the valueless case was already part of the ‘else’, it is the case of symbols with a semantic value that was not.
commit 1bc537008668c83662961a6fe752efec29844371 Author: Akim Demaille <[email protected]> Date: Sun Sep 9 10:06:57 2018 +0200 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. diff --git a/data/c++.m4 b/data/c++.m4 index b535cd8f..0fd46e8e 100644 --- a/data/c++.m4 +++ b/data/c++.m4 @@ -222,12 +222,12 @@ m4_define([b4_symbol_type_declare], ]b4_type_foreach([b4_basic_symbol_constructor_declare])], [[ /// Constructor for valueless symbols. basic_symbol (typename Base::kind_type t]b4_locations_if([, - const location_type& l])[);]])[ + const location_type& l])[); /// Constructor for symbols with semantic value. basic_symbol (typename Base::kind_type t, const semantic_type& v]b4_locations_if([, - const location_type& l])[); + const location_type& l])[);]])[ /// Destroy the symbol. ~basic_symbol (); @@ -317,30 +317,30 @@ m4_define([b4_public_types_define], [other.value])])[ } +]b4_variant_if([[ + // Implementation of basic_symbol constructor for each type. +]b4_type_foreach([b4_basic_symbol_constructor_define])], [[ + /// Constructor for valueless symbols. 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([ + , value ()]b4_locations_if([ , location (l)])[ - {]b4_variant_if([[ - (void) v; - ]b4_symbol_variant([this->type_get ()], [value], [copy], [v])])[} + {} -]b4_variant_if([[ - // Implementation of basic_symbol constructor for each type. -]b4_type_foreach([b4_basic_symbol_constructor_define])], [[ - /// Constructor for valueless symbols. 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_locations_if([ + , 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> ]b4_parser_class_name[::basic_symbol<Base>::~basic_symbol ()
