From a7e46f6e41524c5a91e5e773859817e629c9db0e Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Sun, 2 Sep 2018 11:25:28 +0200 Subject: [PATCH] C++: don't issue the definition of symbol_type when not used Currently, in glr.cc, we emit the definitions of basic_symbol and symbol_type, although there are not used. * data/c++.m4 (b4_public_types_declare): Extract these definitions from here, and move them... (b4_symbol_type_declare): here. (b4_public_types_declare): Also remove the definition of the symbol constructors. * data/lalr1.cc (b4_shared_declarations): Adjust: call b4_symbol_type_declare and b4_symbol_constructor_declare. --- data/c++.m4 | 12 +++++++++--- data/lalr1.cc | 3 +++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/data/c++.m4 b/data/c++.m4 index be1becb2..b535cd8f 100644 --- a/data/c++.m4 +++ b/data/c++.m4 @@ -192,8 +192,15 @@ m4_define([b4_public_types_declare], /// Internal symbol number for tokens (subsumed by symbol_number_type). typedef ]b4_int_type_for([b4_translate])[ token_number_type; +]]) - /// A complete symbol. + +# b4_symbol_type_declare +# ---------------------- +# Define symbol_type, the external type for symbols used for symbol +# constructors. +m4_define([b4_symbol_type_declare], +[[ /// A complete symbol. /// /// Expects its Base type to provide access to the symbol type /// via type_get(). @@ -281,8 +288,7 @@ m4_define([b4_public_types_declare], /// "External" symbols: returned by the scanner. typedef basic_symbol symbol_type; - -]b4_symbol_constructor_declare]) +]]) # b4_public_types_define(hh|cc) diff --git a/data/lalr1.cc b/data/lalr1.cc index 693536a3..4679eb42 100644 --- a/data/lalr1.cc +++ b/data/lalr1.cc @@ -176,6 +176,7 @@ b4_location_define])])[ { public: ]b4_public_types_declare[ +]b4_symbol_type_declare[ /// Build a parser object. ]b4_parser_class_name[ (]b4_parse_param_decl[); virtual ~]b4_parser_class_name[ (); @@ -206,6 +207,8 @@ b4_location_define])])[ /// Report a syntax error. void error (const syntax_error& err); +]b4_symbol_constructor_declare[ + private: /// This class is not copyable. ]b4_parser_class_name[ (const ]b4_parser_class_name[&);