mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-17 16:23:04 +00:00
errors: indent "symbol redeclaration" context
This is the continuation of the work on the readability of errors context. For example, what used to be: input.y:5.10-24: %printer redeclaration for <field2> input.y:3.11-25: previous declaration is now: input.y:5.10-24: %printer redeclaration for <field2> input.y:3.11-25: previous declaration * NEWS: Document this change. * src/symtab.c (symbol_redeclaration, semantic_type_redeclaration, user_token_number_redeclaration, default_tagged_destructor_set, default_tagless_destructor_set, default_tagged_printer_set, default_tagless_printer_set): Use complain_at_indent to output with increased indentation level. * tests/input.at: Apply this change. Signed-off-by: Akim Demaille <akim@lrde.epita.fr>
This commit is contained in:
committed by
Akim Demaille
parent
24d96dd3eb
commit
cbaea0106d
14
NEWS
14
NEWS
@@ -14,6 +14,18 @@ GNU Bison NEWS
|
|||||||
Incorrect definitions of YY_, issued by yacc.c when no parser header is
|
Incorrect definitions of YY_, issued by yacc.c when no parser header is
|
||||||
generated, are removed.
|
generated, are removed.
|
||||||
|
|
||||||
|
** Changes in the format of errors and exceptions output
|
||||||
|
|
||||||
|
This used to be the format of many error reports:
|
||||||
|
|
||||||
|
foo.y:5.10-24: result type clash on merge function 'merge': <t3> != <t2>
|
||||||
|
foo.y:4.13-27: previous declaration
|
||||||
|
|
||||||
|
It is now:
|
||||||
|
|
||||||
|
foo.y:5.10-25: result type clash on merge function 'merge': <t3> != <t2>
|
||||||
|
foo.y:4.13-27: previous declaration
|
||||||
|
|
||||||
* Noteworthy changes in release 2.6.2 (2012-08-03) [stable]
|
* Noteworthy changes in release 2.6.2 (2012-08-03) [stable]
|
||||||
|
|
||||||
** Bug fixes
|
** Bug fixes
|
||||||
@@ -32,7 +44,7 @@ GNU Bison NEWS
|
|||||||
|
|
||||||
* Noteworthy changes in release 2.6.1 (2012-07-30) [stable]
|
* Noteworthy changes in release 2.6.1 (2012-07-30) [stable]
|
||||||
|
|
||||||
Bison no longer executes user-specified M4 code when processing a grammar.
|
Bison no longer executes user-specified M4 code when processing a grammar.
|
||||||
|
|
||||||
** Future Changes
|
** Future Changes
|
||||||
|
|
||||||
|
|||||||
64
src/symtab.c
64
src/symtab.c
@@ -150,16 +150,20 @@ static void
|
|||||||
symbol_redeclaration (symbol *s, const char *what, location first,
|
symbol_redeclaration (symbol *s, const char *what, location first,
|
||||||
location second)
|
location second)
|
||||||
{
|
{
|
||||||
complain_at (second, _("%s redeclaration for %s"), what, s->tag);
|
unsigned i = 0;
|
||||||
complain_at (first, _("previous declaration"));
|
complain_at_indent (second, &i, _("%s redeclaration for %s"), what, s->tag);
|
||||||
|
i += SUB_INDENT;
|
||||||
|
complain_at_indent (first, &i, _("previous declaration"));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
semantic_type_redeclaration (semantic_type *s, const char *what, location first,
|
semantic_type_redeclaration (semantic_type *s, const char *what, location first,
|
||||||
location second)
|
location second)
|
||||||
{
|
{
|
||||||
complain_at (second, _("%s redeclaration for <%s>"), what, s->tag);
|
unsigned i = 0;
|
||||||
complain_at (first, _("previous declaration"));
|
complain_at_indent (second, &i, _("%s redeclaration for <%s>"), what, s->tag);
|
||||||
|
i += SUB_INDENT;
|
||||||
|
complain_at_indent (first, &i, _("previous declaration"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -515,6 +519,7 @@ symbol_pack_processor (void *this, void *null ATTRIBUTE_UNUSED)
|
|||||||
static void
|
static void
|
||||||
user_token_number_redeclaration (int num, symbol *first, symbol *second)
|
user_token_number_redeclaration (int num, symbol *first, symbol *second)
|
||||||
{
|
{
|
||||||
|
unsigned i = 0;
|
||||||
/* User token numbers are not assigned during the parsing, but in a
|
/* User token numbers are not assigned during the parsing, but in a
|
||||||
second step, via a traversal of the symbol table sorted on tag.
|
second step, via a traversal of the symbol table sorted on tag.
|
||||||
|
|
||||||
@@ -526,11 +531,12 @@ user_token_number_redeclaration (int num, symbol *first, symbol *second)
|
|||||||
first = second;
|
first = second;
|
||||||
second = tmp;
|
second = tmp;
|
||||||
}
|
}
|
||||||
complain_at (second->location,
|
complain_at_indent (second->location, &i,
|
||||||
_("user token number %d redeclaration for %s"),
|
_("user token number %d redeclaration for %s"),
|
||||||
num, second->tag);
|
num, second->tag);
|
||||||
complain_at (first->location, _("previous declaration for %s"),
|
complain_at_indent (first->location, &i,
|
||||||
first->tag);
|
_("previous declaration for %s"),
|
||||||
|
first->tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------.
|
/*--------------------------------------------------.
|
||||||
@@ -923,10 +929,12 @@ default_tagged_destructor_set (code_props const *destructor)
|
|||||||
{
|
{
|
||||||
if (default_tagged_destructor.code)
|
if (default_tagged_destructor.code)
|
||||||
{
|
{
|
||||||
complain_at (destructor->location,
|
unsigned i = 0;
|
||||||
_("redeclaration for default tagged %%destructor"));
|
complain_at_indent (destructor->location, &i,
|
||||||
complain_at (default_tagged_destructor.location,
|
_("redeclaration for default tagged %%destructor"));
|
||||||
_("previous declaration"));
|
i += SUB_INDENT;
|
||||||
|
complain_at_indent (default_tagged_destructor.location, &i,
|
||||||
|
_("previous declaration"));
|
||||||
}
|
}
|
||||||
default_tagged_destructor = *destructor;
|
default_tagged_destructor = *destructor;
|
||||||
}
|
}
|
||||||
@@ -936,10 +944,12 @@ default_tagless_destructor_set (code_props const *destructor)
|
|||||||
{
|
{
|
||||||
if (default_tagless_destructor.code)
|
if (default_tagless_destructor.code)
|
||||||
{
|
{
|
||||||
complain_at (destructor->location,
|
unsigned i = 0;
|
||||||
_("redeclaration for default tagless %%destructor"));
|
complain_at_indent (destructor->location, &i,
|
||||||
complain_at (default_tagless_destructor.location,
|
_("redeclaration for default tagless %%destructor"));
|
||||||
_("previous declaration"));
|
i += SUB_INDENT;
|
||||||
|
complain_at_indent (default_tagless_destructor.location, &i,
|
||||||
|
_("previous declaration"));
|
||||||
}
|
}
|
||||||
default_tagless_destructor = *destructor;
|
default_tagless_destructor = *destructor;
|
||||||
}
|
}
|
||||||
@@ -949,10 +959,12 @@ default_tagged_printer_set (code_props const *printer)
|
|||||||
{
|
{
|
||||||
if (default_tagged_printer.code)
|
if (default_tagged_printer.code)
|
||||||
{
|
{
|
||||||
complain_at (printer->location,
|
unsigned i = 0;
|
||||||
_("redeclaration for default tagged %%printer"));
|
complain_at_indent (printer->location, &i,
|
||||||
complain_at (default_tagged_printer.location,
|
_("redeclaration for default tagged %%printer"));
|
||||||
_("previous declaration"));
|
i += SUB_INDENT;
|
||||||
|
complain_at_indent (default_tagged_printer.location, &i,
|
||||||
|
_("previous declaration"));
|
||||||
}
|
}
|
||||||
default_tagged_printer = *printer;
|
default_tagged_printer = *printer;
|
||||||
}
|
}
|
||||||
@@ -962,10 +974,12 @@ default_tagless_printer_set (code_props const *printer)
|
|||||||
{
|
{
|
||||||
if (default_tagless_printer.code)
|
if (default_tagless_printer.code)
|
||||||
{
|
{
|
||||||
complain_at (printer->location,
|
unsigned i = 0;
|
||||||
_("redeclaration for default tagless %%printer"));
|
complain_at_indent (printer->location, &i,
|
||||||
complain_at (default_tagless_printer.location,
|
_("redeclaration for default tagless %%printer"));
|
||||||
_("previous declaration"));
|
i += SUB_INDENT;
|
||||||
|
complain_at_indent (default_tagless_printer.location, &i,
|
||||||
|
_("previous declaration"));
|
||||||
}
|
}
|
||||||
default_tagless_printer = *printer;
|
default_tagless_printer = *printer;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -206,29 +206,29 @@ start: ;
|
|||||||
|
|
||||||
AT_BISON_CHECK([input.y], [1], [],
|
AT_BISON_CHECK([input.y], [1], [],
|
||||||
[[input.y:1.13-29: redeclaration for default tagged %destructor
|
[[input.y:1.13-29: redeclaration for default tagged %destructor
|
||||||
input.y:1.13-29: previous declaration
|
input.y:1.13-29: previous declaration
|
||||||
input.y:2.10-24: redeclaration for default tagged %printer
|
input.y:2.10-24: redeclaration for default tagged %printer
|
||||||
input.y:2.10-24: previous declaration
|
input.y:2.10-24: previous declaration
|
||||||
input.y:4.13-29: redeclaration for default tagged %destructor
|
input.y:4.13-29: redeclaration for default tagged %destructor
|
||||||
input.y:1.13-29: previous declaration
|
input.y:1.13-29: previous declaration
|
||||||
input.y:5.10-24: redeclaration for default tagged %printer
|
input.y:5.10-24: redeclaration for default tagged %printer
|
||||||
input.y:2.10-24: previous declaration
|
input.y:2.10-24: previous declaration
|
||||||
input.y:7.13-29: redeclaration for default tagless %destructor
|
input.y:7.13-29: redeclaration for default tagless %destructor
|
||||||
input.y:7.13-29: previous declaration
|
input.y:7.13-29: previous declaration
|
||||||
input.y:8.10-24: redeclaration for default tagless %printer
|
input.y:8.10-24: redeclaration for default tagless %printer
|
||||||
input.y:8.10-24: previous declaration
|
input.y:8.10-24: previous declaration
|
||||||
input.y:10.13-29: redeclaration for default tagless %destructor
|
input.y:10.13-29: redeclaration for default tagless %destructor
|
||||||
input.y:7.13-29: previous declaration
|
input.y:7.13-29: previous declaration
|
||||||
input.y:11.10-24: redeclaration for default tagless %printer
|
input.y:11.10-24: redeclaration for default tagless %printer
|
||||||
input.y:8.10-24: previous declaration
|
input.y:8.10-24: previous declaration
|
||||||
input.y:17.13-29: redeclaration for default tagged %destructor
|
input.y:17.13-29: redeclaration for default tagged %destructor
|
||||||
input.y:4.13-29: previous declaration
|
input.y:4.13-29: previous declaration
|
||||||
input.y:18.10-24: redeclaration for default tagged %printer
|
input.y:18.10-24: redeclaration for default tagged %printer
|
||||||
input.y:5.10-24: previous declaration
|
input.y:5.10-24: previous declaration
|
||||||
input.y:20.13-29: redeclaration for default tagless %destructor
|
input.y:20.13-29: redeclaration for default tagless %destructor
|
||||||
input.y:10.13-29: previous declaration
|
input.y:10.13-29: previous declaration
|
||||||
input.y:21.10-24: redeclaration for default tagless %printer
|
input.y:21.10-24: redeclaration for default tagless %printer
|
||||||
input.y:11.10-24: previous declaration
|
input.y:11.10-24: previous declaration
|
||||||
]])
|
]])
|
||||||
|
|
||||||
AT_CLEANUP
|
AT_CLEANUP
|
||||||
@@ -257,21 +257,21 @@ start: ;
|
|||||||
|
|
||||||
AT_BISON_CHECK([input.y], [1], [],
|
AT_BISON_CHECK([input.y], [1], [],
|
||||||
[[input.y:4.13-29: %destructor redeclaration for <field1>
|
[[input.y:4.13-29: %destructor redeclaration for <field1>
|
||||||
input.y:1.13-29: previous declaration
|
input.y:1.13-29: previous declaration
|
||||||
input.y:4.13-29: %destructor redeclaration for <field1>
|
input.y:4.13-29: %destructor redeclaration for <field1>
|
||||||
input.y:4.13-29: previous declaration
|
input.y:4.13-29: previous declaration
|
||||||
input.y:5.10-24: %printer redeclaration for <field2>
|
input.y:5.10-24: %printer redeclaration for <field2>
|
||||||
input.y:2.10-24: previous declaration
|
input.y:2.10-24: previous declaration
|
||||||
input.y:5.10-24: %printer redeclaration for <field2>
|
input.y:5.10-24: %printer redeclaration for <field2>
|
||||||
input.y:5.10-24: previous declaration
|
input.y:5.10-24: previous declaration
|
||||||
input.y:11.13-29: %destructor redeclaration for <field1>
|
input.y:11.13-29: %destructor redeclaration for <field1>
|
||||||
input.y:4.13-29: previous declaration
|
input.y:4.13-29: previous declaration
|
||||||
input.y:11.13-29: %destructor redeclaration for <field2>
|
input.y:11.13-29: %destructor redeclaration for <field2>
|
||||||
input.y:1.13-29: previous declaration
|
input.y:1.13-29: previous declaration
|
||||||
input.y:12.10-24: %printer redeclaration for <field1>
|
input.y:12.10-24: %printer redeclaration for <field1>
|
||||||
input.y:2.10-24: previous declaration
|
input.y:2.10-24: previous declaration
|
||||||
input.y:12.10-24: %printer redeclaration for <field2>
|
input.y:12.10-24: %printer redeclaration for <field2>
|
||||||
input.y:5.10-24: previous declaration
|
input.y:5.10-24: previous declaration
|
||||||
]])
|
]])
|
||||||
|
|
||||||
AT_CLEANUP
|
AT_CLEANUP
|
||||||
@@ -369,13 +369,13 @@ exp: foo;
|
|||||||
|
|
||||||
AT_BISON_CHECK([input.y], [1], [],
|
AT_BISON_CHECK([input.y], [1], [],
|
||||||
[[input.y:8.7-11: %type redeclaration for foo
|
[[input.y:8.7-11: %type redeclaration for foo
|
||||||
input.y:3.7-11: previous declaration
|
input.y:3.7-11: previous declaration
|
||||||
input.y:10.13-17: %destructor redeclaration for foo
|
input.y:10.13-17: %destructor redeclaration for foo
|
||||||
input.y:5.13-17: previous declaration
|
input.y:5.13-17: previous declaration
|
||||||
input.y:9.10-14: %printer redeclaration for foo
|
input.y:9.10-14: %printer redeclaration for foo
|
||||||
input.y:4.10-14: previous declaration
|
input.y:4.10-14: previous declaration
|
||||||
input.y:11.1-5: %left redeclaration for foo
|
input.y:11.1-5: %left redeclaration for foo
|
||||||
input.y:6.1-5: previous declaration
|
input.y:6.1-5: previous declaration
|
||||||
]])
|
]])
|
||||||
|
|
||||||
AT_CLEANUP
|
AT_CLEANUP
|
||||||
@@ -693,7 +693,7 @@ start: DECIMAL_1 HEXADECIMAL_2;
|
|||||||
|
|
||||||
AT_BISON_CHECK([redecl.y], [1], [],
|
AT_BISON_CHECK([redecl.y], [1], [],
|
||||||
[[redecl.y:10.10-22: user token number 11259375 redeclaration for HEXADECIMAL_1
|
[[redecl.y:10.10-22: user token number 11259375 redeclaration for HEXADECIMAL_1
|
||||||
redecl.y:9.8-16: previous declaration for DECIMAL_1
|
redecl.y:9.8-16: previous declaration for DECIMAL_1
|
||||||
redecl.y:12.10-18: user token number 16702650 redeclaration for DECIMAL_2
|
redecl.y:12.10-18: user token number 16702650 redeclaration for DECIMAL_2
|
||||||
redecl.y:11.10-22: previous declaration for HEXADECIMAL_2
|
redecl.y:11.10-22: previous declaration for HEXADECIMAL_2
|
||||||
]])
|
]])
|
||||||
|
|||||||
Reference in New Issue
Block a user