mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 20:33:03 +00:00
* src/reader.c (symbol_should_be_used): Renamed from symbol_typed_p.
All used changed. Check whether the symbol has a destructor, not whether it is typed. * tests/input.at (AT_CHECK_UNUSED_VALUES): Add a destructor, so that the values are still reported as unused. All line numbers adjusted.
This commit is contained in:
@@ -1,3 +1,12 @@
|
||||
2006-01-27 Paul Eggert <eggert@cs.ucla.edu>
|
||||
|
||||
* src/reader.c (symbol_should_be_used): Renamed from symbol_typed_p.
|
||||
All used changed. Check whether the symbol has a destructor,
|
||||
not whether it is typed.
|
||||
* tests/input.at (AT_CHECK_UNUSED_VALUES): Add a destructor, so
|
||||
that the values are still reported as unused. All line numbers
|
||||
adjusted.
|
||||
|
||||
2006-01-23 Paul Eggert <eggert@cs.ucla.edu>
|
||||
|
||||
Work around a bug in bro 0.8, which underparenthesizes its
|
||||
|
||||
19
src/reader.c
19
src/reader.c
@@ -212,17 +212,16 @@ grammar_current_rule_begin (symbol *lhs, location loc)
|
||||
}
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------.
|
||||
| A symbol is typed if it has a declared %type, or if it is a |
|
||||
| mid-rule symbol (i.e., the generated LHS replacing a mid-rule |
|
||||
| action) that was assigned to, as in `exp: { $$ = 1; } { $$ = $1; |
|
||||
| }'. |
|
||||
`-----------------------------------------------------------------*/
|
||||
/*----------------------------------------------------------------------.
|
||||
| A symbol should be used if it has a destructor, or if it is a |
|
||||
| mid-rule symbol (i.e., the generated LHS replacing a mid-rule |
|
||||
| action) that was assigned to, as in "exp: { $$ = 1; } { $$ = $1; }". |
|
||||
`----------------------------------------------------------------------*/
|
||||
|
||||
static bool
|
||||
symbol_typed_p (const symbol_list *s)
|
||||
symbol_should_be_used (symbol_list const *s)
|
||||
{
|
||||
return (s->sym->type_name
|
||||
return (s->sym->destructor
|
||||
|| (s->midrule && s->midrule->used));
|
||||
}
|
||||
|
||||
@@ -261,13 +260,13 @@ grammar_rule_check (const symbol_list *r)
|
||||
_("empty rule for typed nonterminal, and no action"));
|
||||
}
|
||||
|
||||
/* Check that typed symbol values are used. */
|
||||
/* Check that symbol values that should be used are in fact used. */
|
||||
{
|
||||
symbol_list const *l = r;
|
||||
int n = 0;
|
||||
for (; l && l->sym; l = l->next, ++n)
|
||||
if (! (l->used
|
||||
|| !symbol_typed_p (l)
|
||||
|| !symbol_should_be_used (l)
|
||||
/* The default action, $$ = $1, `uses' both. */
|
||||
|| (!r->action && (n == 0 || n == 1))))
|
||||
{
|
||||
|
||||
@@ -92,6 +92,7 @@ m4_define([AT_CHECK_UNUSED_VALUES],
|
||||
AT_DATA([input.y],
|
||||
[[%token <integer> INT
|
||||
%type <integer> exp
|
||||
%destructor { destroy ($$); } INT exp
|
||||
%%
|
||||
exp:
|
||||
$1
|
||||
@@ -106,56 +107,56 @@ AT_CLEANUP
|
||||
])
|
||||
|
||||
AT_CHECK_UNUSED_VALUES([INT { } INT { } INT { }],
|
||||
[input.y:5.3-25: warning: unset value: $$
|
||||
input.y:5.3-25: warning: unused value: $1
|
||||
input.y:5.3-25: warning: unused value: $3
|
||||
input.y:5.3-25: warning: unused value: $5
|
||||
[input.y:6.3-25: warning: unset value: $$
|
||||
input.y:6.3-25: warning: unused value: $1
|
||||
input.y:6.3-25: warning: unused value: $3
|
||||
input.y:6.3-25: warning: unused value: $5
|
||||
])
|
||||
|
||||
AT_CHECK_UNUSED_VALUES([INT { $1 } INT { } INT { }],
|
||||
[input.y:5.3-28: warning: unset value: $$
|
||||
input.y:5.3-28: warning: unused value: $3
|
||||
input.y:5.3-28: warning: unused value: $5
|
||||
[input.y:6.3-28: warning: unset value: $$
|
||||
input.y:6.3-28: warning: unused value: $3
|
||||
input.y:6.3-28: warning: unused value: $5
|
||||
])
|
||||
|
||||
AT_CHECK_UNUSED_VALUES([INT { } INT { $1 } INT { }],
|
||||
[input.y:5.3-28: warning: unset value: $$
|
||||
input.y:5.3-28: warning: unused value: $3
|
||||
input.y:5.3-28: warning: unused value: $5
|
||||
[input.y:6.3-28: warning: unset value: $$
|
||||
input.y:6.3-28: warning: unused value: $3
|
||||
input.y:6.3-28: warning: unused value: $5
|
||||
])
|
||||
|
||||
AT_CHECK_UNUSED_VALUES([INT { } INT { } INT { $1 }],
|
||||
[input.y:5.3-29: warning: unset value: $$
|
||||
input.y:5.3-29: warning: unused value: $3
|
||||
input.y:5.3-29: warning: unused value: $5
|
||||
[input.y:6.3-29: warning: unset value: $$
|
||||
input.y:6.3-29: warning: unused value: $3
|
||||
input.y:6.3-29: warning: unused value: $5
|
||||
])
|
||||
|
||||
AT_CHECK_UNUSED_VALUES([INT { } INT { } INT { $$ = $1 + $3 + $5; }])
|
||||
|
||||
# Checking mid-rule values.
|
||||
AT_CHECK_UNUSED_VALUES([INT { $$ } INT { $$ } INT { }],
|
||||
[input.y:5.3-31: warning: unset value: $$
|
||||
input.y:5.3-31: warning: unused value: $1
|
||||
input.y:5.3-31: warning: unused value: $2
|
||||
input.y:5.3-31: warning: unused value: $3
|
||||
input.y:5.3-31: warning: unused value: $4
|
||||
input.y:5.3-31: warning: unused value: $5
|
||||
[input.y:6.3-31: warning: unset value: $$
|
||||
input.y:6.3-31: warning: unused value: $1
|
||||
input.y:6.3-31: warning: unused value: $2
|
||||
input.y:6.3-31: warning: unused value: $3
|
||||
input.y:6.3-31: warning: unused value: $4
|
||||
input.y:6.3-31: warning: unused value: $5
|
||||
])
|
||||
|
||||
AT_CHECK_UNUSED_VALUES([INT { $$ } INT { $$ = $2 } INT { }],
|
||||
[input.y:5.3-36: warning: unset value: $$
|
||||
input.y:5.3-36: warning: unused value: $1
|
||||
input.y:5.3-36: warning: unused value: $3
|
||||
input.y:5.3-36: warning: unused value: $4
|
||||
input.y:5.3-36: warning: unused value: $5
|
||||
[input.y:6.3-36: warning: unset value: $$
|
||||
input.y:6.3-36: warning: unused value: $1
|
||||
input.y:6.3-36: warning: unused value: $3
|
||||
input.y:6.3-36: warning: unused value: $4
|
||||
input.y:6.3-36: warning: unused value: $5
|
||||
])
|
||||
|
||||
# AT_CHECK_UNUSED_VALUES([INT { $$ } { $$ = $2 } { }],
|
||||
# [input.y:5.3-36: warning: unset value: $$
|
||||
# input.y:5.3-36: warning: unused value: $1
|
||||
# input.y:5.3-36: warning: unused value: $3
|
||||
# input.y:5.3-36: warning: unused value: $4
|
||||
# input.y:5.3-36: warning: unused value: $5
|
||||
# [input.y:6.3-36: warning: unset value: $$
|
||||
# input.y:6.3-36: warning: unused value: $1
|
||||
# input.y:6.3-36: warning: unused value: $3
|
||||
# input.y:6.3-36: warning: unused value: $4
|
||||
# input.y:6.3-36: warning: unused value: $5
|
||||
# ])
|
||||
|
||||
AT_CHECK_UNUSED_VALUES([INT { $$ = $1 } INT { $$ = $2 + $3 } INT { $$ = $4 + $5 }])
|
||||
|
||||
Reference in New Issue
Block a user