C++: finish propagating the unsigned->signed conversion in locations

* data/skeletons/location.cc: Remove the u (for unsigned) suffix from
the initial line and column.
* NEWS: AFAICT, only C++ backends have their location types changed.
This commit is contained in:
Akim Demaille
2019-10-29 09:08:28 +01:00
parent c53b379784
commit 28f1e1546c
3 changed files with 18 additions and 14 deletions

7
NEWS
View File

@@ -8,9 +8,10 @@ GNU Bison NEWS
longer treated as end-of-lines. This changes the diagnostics, and in longer treated as end-of-lines. This changes the diagnostics, and in
particular their locations. particular their locations.
Line numbers and columns are now represented as 'int' not 'unsigned', In C++, line numbers and columns are now represented as 'int' not
so that integer overflow on positions is easily checkable via 'gcc 'unsigned', so that integer overflow on positions is easily checkable via
-fsanitize=undefined' and the like. This affects the API for positions. 'gcc -fsanitize=undefined' and the like. This affects the API for
positions.
** Bug fixes ** Bug fixes

7
TODO
View File

@@ -53,6 +53,7 @@ file", or "end of input", whatever. See how lalr1.java does that.
** api.token.raw ** api.token.raw
Maybe we should exhibit the YYUNDEFTOK token. It could also be assigned a Maybe we should exhibit the YYUNDEFTOK token. It could also be assigned a
semantic value so that yyerror could be used to report invalid lexemes. semantic value so that yyerror could be used to report invalid lexemes.
See also the item "$undefined" below.
* Bison 3.6 * Bison 3.6
** Unit rules / Injection rules (Akim Demaille) ** Unit rules / Injection rules (Akim Demaille)
@@ -177,6 +178,8 @@ in black, so it doesn't show in my terminal :-)
^ ^
1 error generated. 1 error generated.
See also the item "Complaint submessage indentation" below.
** Better design for diagnostics ** Better design for diagnostics
The current implementation of diagnostics is adhoc, it grew organically. It The current implementation of diagnostics is adhoc, it grew organically. It
works as a series of calls to several functions, with dependency of the works as a series of calls to several functions, with dependency of the
@@ -212,7 +215,7 @@ page:
https://gcc.gnu.org/onlinedocs/gcc/Diagnostic-Message-Formatting-Options.html https://gcc.gnu.org/onlinedocs/gcc/Diagnostic-Message-Formatting-Options.html
** consistency ** consistency
token vs terminal token vs terminal, variable vs non terminal.
** C++ ** C++
Move to int everywhere instead of unsigned? stack_size, etc. The parser Move to int everywhere instead of unsigned? stack_size, etc. The parser
@@ -543,7 +546,7 @@ Paul notes:
tokens, either via escapes (e.g., "x\0y") or via a NUL byte in tokens, either via escapes (e.g., "x\0y") or via a NUL byte in
the source code. This should get fixed. the source code. This should get fixed.
* Broken options ? * Broken options?
** %token-table ** %token-table
** Skeleton strategy ** Skeleton strategy
Must we keep %token-table? Must we keep %token-table?

View File

@@ -65,8 +65,8 @@ m4_define([b4_location_define],
public:]m4_ifdef([b4_location_constructors], [[ public:]m4_ifdef([b4_location_constructors], [[
/// Construct a position. /// Construct a position.
explicit position (]b4_percent_define_get([[filename_type]])[* f = YY_NULLPTR, explicit position (]b4_percent_define_get([[filename_type]])[* f = YY_NULLPTR,
int l = ]b4_location_initial_line[u, int l = ]b4_location_initial_line[,
int c = ]b4_location_initial_column[u) int c = ]b4_location_initial_column[)
: filename (f) : filename (f)
, line (l) , line (l)
, column (c) , column (c)
@@ -75,8 +75,8 @@ m4_define([b4_location_define],
]])[ ]])[
/// Initialization. /// Initialization.
void initialize (]b4_percent_define_get([[filename_type]])[* fn = YY_NULLPTR, void initialize (]b4_percent_define_get([[filename_type]])[* fn = YY_NULLPTR,
int l = ]b4_location_initial_line[u, int l = ]b4_location_initial_line[,
int c = ]b4_location_initial_column[u) int c = ]b4_location_initial_column[)
{ {
filename = fn; filename = fn;
line = l; line = l;
@@ -90,7 +90,7 @@ m4_define([b4_location_define],
{ {
if (count) if (count)
{ {
column = ]b4_location_initial_column[u; column = ]b4_location_initial_column[;
line = add_ (line, count, ]b4_location_initial_line[); line = add_ (line, count, ]b4_location_initial_line[);
} }
} }
@@ -196,8 +196,8 @@ m4_define([b4_location_define],
/// Construct a 0-width location in \a f, \a l, \a c. /// Construct a 0-width location in \a f, \a l, \a c.
explicit location (]b4_percent_define_get([[filename_type]])[* f, explicit location (]b4_percent_define_get([[filename_type]])[* f,
int l = ]b4_location_initial_line[u, int l = ]b4_location_initial_line[,
int c = ]b4_location_initial_column[u) int c = ]b4_location_initial_column[)
: begin (f, l, c) : begin (f, l, c)
, end (f, l, c) , end (f, l, c)
{} {}
@@ -205,8 +205,8 @@ m4_define([b4_location_define],
])[ ])[
/// Initialization. /// Initialization.
void initialize (]b4_percent_define_get([[filename_type]])[* f = YY_NULLPTR, void initialize (]b4_percent_define_get([[filename_type]])[* f = YY_NULLPTR,
int l = ]b4_location_initial_line[u, int l = ]b4_location_initial_line[,
int c = ]b4_location_initial_column[u) int c = ]b4_location_initial_column[)
{ {
begin.initialize (f, l, c); begin.initialize (f, l, c);
end = begin; end = begin;