mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-16 15:53:03 +00:00
undefined but unused is a warning
* src/symtab.c (symbol_check_defined): Undeclared symbols are only a warning. * tests/input.at (Undeclared symbols used for a printer or destructor): Rename as... (Undefined symbols): this, and check this case. * NEWS: Doc it.
This commit is contained in:
9
NEWS
9
NEWS
@@ -36,18 +36,17 @@ GNU Bison NEWS
|
|||||||
3.28-34: warning: type <type3> is used, but is not associated to any symbol
|
3.28-34: warning: type <type3> is used, but is not associated to any symbol
|
||||||
4.28-34: warning: type <type4> is used, but is not associated to any symbol
|
4.28-34: warning: type <type4> is used, but is not associated to any symbol
|
||||||
|
|
||||||
*** Undeclared symbols
|
*** Undefined but unused symbols
|
||||||
|
|
||||||
Bison used to raise an error for %printer and %destructor directives for
|
Bison used to raise an error for undefined symbols that are not used in
|
||||||
undefined symbols.
|
the grammar. This is now only a warning.
|
||||||
|
|
||||||
%printer {} symbol1
|
%printer {} symbol1
|
||||||
%destructor {} symbol2
|
%destructor {} symbol2
|
||||||
|
%type <type> symbol3
|
||||||
%%
|
%%
|
||||||
exp: "a";
|
exp: "a";
|
||||||
|
|
||||||
This is now only a warning.
|
|
||||||
|
|
||||||
*** Useless destructors or printers
|
*** Useless destructors or printers
|
||||||
|
|
||||||
Bison now warns about useless destructors or printers. In the following
|
Bison now warns about useless destructors or printers. In the following
|
||||||
|
|||||||
26
src/symtab.c
26
src/symtab.c
@@ -383,26 +383,12 @@ symbol_check_defined (symbol *sym)
|
|||||||
{
|
{
|
||||||
if (sym->class == unknown_sym)
|
if (sym->class == unknown_sym)
|
||||||
{
|
{
|
||||||
switch (sym->status)
|
assert (sym->status != declared);
|
||||||
{
|
complain_at (sym->location,
|
||||||
case used:
|
sym->status == needed ? complaint : Wother,
|
||||||
complain_at (sym->location, Wother,
|
_("symbol %s is used, but is not defined as a token"
|
||||||
_("symbol %s is used, but is not defined as a token"
|
" and has no rules"),
|
||||||
" and has no rules"),
|
sym->tag);
|
||||||
sym->tag);
|
|
||||||
break;
|
|
||||||
case undeclared:
|
|
||||||
case needed:
|
|
||||||
complain_at (sym->location, complaint,
|
|
||||||
_("symbol %s is used, but is not defined as a token"
|
|
||||||
" and has no rules"),
|
|
||||||
sym->tag);
|
|
||||||
break;
|
|
||||||
case declared:
|
|
||||||
/* If declared, then sym->class != unknown_sym. */
|
|
||||||
assert (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
sym->class = nterm_sym;
|
sym->class = nterm_sym;
|
||||||
sym->number = nvars++;
|
sym->number = nvars++;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -271,16 +271,16 @@ input.y:5.10-24: previous declaration
|
|||||||
|
|
||||||
AT_CLEANUP
|
AT_CLEANUP
|
||||||
|
|
||||||
## ----------------------------------------------------- ##
|
## ------------------- ##
|
||||||
## Undeclared symbols used for a printer or destructor. ##
|
## Undefined symbols. ##
|
||||||
## ----------------------------------------------------- ##
|
## ------------------- ##
|
||||||
|
|
||||||
AT_SETUP([Undeclared symbols used for a printer or destructor])
|
AT_SETUP([Undefined symbols])
|
||||||
|
|
||||||
AT_DATA([[input.y]],
|
AT_DATA([[input.y]],
|
||||||
[[%printer {} foo baz
|
[[%printer {} foo baz
|
||||||
%destructor {} bar
|
%destructor {} bar
|
||||||
|
%type <foo> qux
|
||||||
%%
|
%%
|
||||||
exp: bar;
|
exp: bar;
|
||||||
]])
|
]])
|
||||||
@@ -289,6 +289,7 @@ AT_BISON_CHECK([input.y], [1], [],
|
|||||||
[[input.y:2.16-18: symbol bar is used, but is not defined as a token and has no rules
|
[[input.y:2.16-18: symbol bar is used, but is not defined as a token and has no rules
|
||||||
input.y:1.17-19: warning: symbol baz is used, but is not defined as a token and has no rules [-Wother]
|
input.y:1.17-19: warning: symbol baz is used, but is not defined as a token and has no rules [-Wother]
|
||||||
input.y:1.13-15: warning: symbol foo is used, but is not defined as a token and has no rules [-Wother]
|
input.y:1.13-15: warning: symbol foo is used, but is not defined as a token and has no rules [-Wother]
|
||||||
|
input.y:3.13-15: warning: symbol qux is used, but is not defined as a token and has no rules [-Wother]
|
||||||
]])
|
]])
|
||||||
|
|
||||||
AT_CLEANUP
|
AT_CLEANUP
|
||||||
|
|||||||
Reference in New Issue
Block a user