mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 20:33:03 +00:00
warnings: raise warning for useless printers or destructors
* src/scan-code.h (code_props): Add field 'is_used'. (CODE_PROPS_NONE_INIT): Adjust. * src/scan-code.l (code_props_plain_init, code_props_symbol_action_init) (code_props_rule_action_init): Instead of implementing several times the initialization of the code_props structures, use code_props_none_init. * src/symtab.c (symbol_check_defined): If a symbol does not have a destructor (resp. printer) but has a type which has a destructor (resp. printer), then set field 'is_used' to true. (semantic_type_check_defined): If a type has a destructor (resp. printer) but all symbols of this type have already a destructor (resp. printer), then raise a warning. * tests/input.at (Useless printers or destructors): New. Signed-off-by: Akim Demaille <akim@lrde.epita.fr>
This commit is contained in:
committed by
Akim Demaille
parent
9641b918ba
commit
ea9a35c605
@@ -69,6 +69,10 @@ typedef struct code_props {
|
||||
*/
|
||||
bool is_predicate;
|
||||
|
||||
/**
|
||||
* Whether this is actually used (i.e., not completely masked by
|
||||
* other code props). */
|
||||
bool is_used;
|
||||
|
||||
/** \c NULL iff \c code_props::kind is not \c CODE_PROPS_RULE_ACTION. */
|
||||
struct symbol_list *rule;
|
||||
@@ -86,8 +90,17 @@ typedef struct code_props {
|
||||
void code_props_none_init (code_props *self);
|
||||
|
||||
/** Equivalent to \c code_props_none_init. */
|
||||
#define CODE_PROPS_NONE_INIT \
|
||||
{CODE_PROPS_NONE, NULL, EMPTY_LOCATION_INIT, false, false, NULL, NULL}
|
||||
#define CODE_PROPS_NONE_INIT \
|
||||
{ \
|
||||
/* .kind = */ CODE_PROPS_NONE, \
|
||||
/* .code = */ NULL, \
|
||||
/* .location = */ EMPTY_LOCATION_INIT, \
|
||||
/* .is_value_used = */ false, \
|
||||
/* .is_predicate = */ false, \
|
||||
/* .is_used = */ false, \
|
||||
/* .rule = */ NULL, \
|
||||
/* .named_ref = */ NULL \
|
||||
}
|
||||
|
||||
/** Initialized by \c CODE_PROPS_NONE_INIT with no further modification. */
|
||||
extern code_props const code_props_none;
|
||||
|
||||
Reference in New Issue
Block a user