mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 12:23:04 +00:00
merge branch 'maint'
* upstream/maint: maint: post-release administrivia version 3.5.3 news: update for 3.5.3 yacc.c: make sure we properly propagated the user's number for error diagnostics: don't crash because of repeated definitions of error style: initialize some struct members diagnostics: beware of zero-width characters diagnostics: be sure to close the styling when lines are too short muscles: fix incorrect decoding of $ code: be robust to reference with invalid tags build: fix typo doc: update recommandation for libtextstyle style: comment changes examples: use consistently the GFDL header for readmes style: remove useless declarations typo: succesful -> successful README: point to tests/bison, and document --trace gnulib: update maint: post-release administrivia
This commit is contained in:
@@ -37,15 +37,15 @@ AT_BISON_OPTION_PUSHDEFS
|
||||
|
||||
AT_DATA_GRAMMAR([[input.y]], [$2])
|
||||
|
||||
AT_DATA([experr], [$4])
|
||||
|
||||
# For some reason, literal ^M in the input are removed and don't end
|
||||
# in `input.y`. So use the two-character ^M represent it, and let
|
||||
# Perl insert real CR characters.
|
||||
if grep '\^M' input.y >/dev/null; then
|
||||
AT_PERL_REQUIRE([-pi -e 's{\^M}{\r}gx' input.y])
|
||||
if $EGREP ['\^M|\\[0-9][0-9][0-9]'] input.y experr >/dev/null; then
|
||||
AT_PERL_REQUIRE([-pi -e 's{\^M}{\r}g;s{\\(\d{3}|.)}{$v = $[]1; $v =~ /\A\d+\z/ ? chr($v) : $v}ge' input.y experr])
|
||||
fi
|
||||
|
||||
AT_DATA([experr], [$4])
|
||||
|
||||
AT_CHECK([LC_ALL="$locale" $5 bison -fcaret --color=debug -Wall input.y], [$3], [], [experr])
|
||||
|
||||
# When no style, same messages, but without style.
|
||||
@@ -152,6 +152,65 @@ input.y: <warning>warning:</warning> fix-its can be applied. Rerun with option
|
||||
]])
|
||||
|
||||
|
||||
|
||||
## ------------------------------------- ##
|
||||
## Line is too short, and then you die. ##
|
||||
## ------------------------------------- ##
|
||||
|
||||
# We trust the "#line", since that's what allows us to quote the
|
||||
# actual source from which the gramar file was generated. But #line
|
||||
# can also be wrong, and point to a line which is shorter that the bad
|
||||
# one. In which case we can easily forget to close the styling.
|
||||
#
|
||||
# Be sure to have #line point to a line long enough to open the
|
||||
# styling, but not enough to close it.
|
||||
|
||||
AT_TEST([[Line is too short, and then you die]],
|
||||
[[// Beware that there are 9 lines inserted before (including this one).
|
||||
#line 12
|
||||
%token foo 123
|
||||
%token foo 123123
|
||||
%token foo 123
|
||||
%%
|
||||
exp:
|
||||
]],
|
||||
[1],
|
||||
[[input.y:13.8-10: <warning>warning:</warning> symbol foo redeclared [<warning>-Wother</warning>]
|
||||
13 | %token <warning>foo</warning> 123
|
||||
| <warning>^~~</warning>
|
||||
input.y:12.8-10: <note>note:</note> previous declaration
|
||||
12 | %token <note>foo</note> 123123
|
||||
| <note>^~~</note>
|
||||
input.y:13.12-17: <error>error:</error> redefining user token number of foo
|
||||
13 | %token foo <error>123</error>
|
||||
| <error>^~~~~~</error>
|
||||
input.y:14.8-10: <warning>warning:</warning> symbol foo redeclared [<warning>-Wother</warning>]
|
||||
14 | %%
|
||||
| <warning>^~~</warning>
|
||||
input.y:12.8-10: <note>note:</note> previous declaration
|
||||
12 | %token <note>foo</note> 123123
|
||||
| <note>^~~</note>
|
||||
]])
|
||||
|
||||
|
||||
## ----------------------- ##
|
||||
## Zero-width characters. ##
|
||||
## ----------------------- ##
|
||||
|
||||
# We used to open twice the styling for characters that have a
|
||||
# zero-width on display (e.g., \005).
|
||||
|
||||
AT_TEST([[Zero-width characters]],
|
||||
[[%%
|
||||
exp: an\005error.
|
||||
]],
|
||||
[1],
|
||||
[[input.y:10.8: <error>error:</error> invalid character: '\\005'
|
||||
10 | exp: an<error>\005</error>error.
|
||||
| <error>^</error>
|
||||
]])
|
||||
|
||||
|
||||
## -------------------------------------- ##
|
||||
## Tabulations and multibyte characters. ##
|
||||
## -------------------------------------- ##
|
||||
@@ -262,7 +321,7 @@ input.y:10.1-27: <error>error:</error> %define variable 'error2' is not used
|
||||
## ----------------- ##
|
||||
|
||||
# Carriage-return used to count as a newline in the scanner, and not
|
||||
# in diagnostics. Resulting in all sort of nice bugs.
|
||||
# in diagnostics. Resulting in all kinds of nice bugs.
|
||||
|
||||
AT_TEST([[Carriage return]],
|
||||
[[^M^M^M^M^M^M^M^M^M^M^M^M^M^M^M^M^M^M^M^M^M^M^M^M^M^M^M^M
|
||||
|
||||
@@ -298,6 +298,52 @@ input.y:8.14: error: unexpected integer literal
|
||||
AT_CLEANUP
|
||||
|
||||
|
||||
## ---------------------------- ##
|
||||
## Redefining the error token. ##
|
||||
## ---------------------------- ##
|
||||
|
||||
AT_SETUP([Redefining the error token])
|
||||
|
||||
# We used to crash when trying to display the original definition of
|
||||
# "error", which is a builtin without any location.
|
||||
|
||||
AT_DATA([input.y],
|
||||
[[%token error 123
|
||||
%token error 124
|
||||
%%
|
||||
exp:
|
||||
]])
|
||||
|
||||
AT_BISON_CHECK([-fcaret input.y], [1], [],
|
||||
[[input.y:2.8-12: warning: symbol error redeclared [-Wother]
|
||||
2 | %token error 124
|
||||
| ^~~~~
|
||||
input.y:1.8-12: note: previous declaration
|
||||
1 | %token error 123
|
||||
| ^~~~~
|
||||
input.y:2.14-16: error: redefining user token number of error
|
||||
2 | %token error 124
|
||||
| ^~~
|
||||
]])
|
||||
|
||||
# While at it, make sure we properly used the user's number for
|
||||
# "error".
|
||||
AT_DATA([input.y],
|
||||
[[%token error 123
|
||||
%%
|
||||
exp:
|
||||
]])
|
||||
|
||||
AT_BISON_CHECK([input.y])
|
||||
|
||||
AT_CHECK([$EGREP -E '123|256' input.tab.c], [],
|
||||
[[ 0, 123, 257
|
||||
#define YYERRCODE 123
|
||||
]])
|
||||
|
||||
AT_CLEANUP
|
||||
|
||||
|
||||
## ------------------ ##
|
||||
## Dangling aliases. ##
|
||||
## ------------------ ##
|
||||
@@ -2069,6 +2115,25 @@ input.y:1.1-34: note: accepted value: 'consistent'
|
||||
input.y:1.1-34: note: accepted value: 'accepting'
|
||||
]])
|
||||
|
||||
# Check escapes.
|
||||
AT_DATA([[input.y]],
|
||||
[[%define lr.default-reduction {[$@]}
|
||||
%%
|
||||
start: %empty;
|
||||
]])
|
||||
AT_BISON_CHECK([[-fcaret input.y]], [[1]], [[]],
|
||||
[[input.y:1.1-35: warning: %define variable 'lr.default-reduction' requires keyword values [-Wdeprecated]
|
||||
1 | %define lr.default-reduction {[$@]}
|
||||
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
input.y:1.1-35: error: invalid value for %define variable 'lr.default-reduction': '[$@]'
|
||||
1 | %define lr.default-reduction {[$@]}
|
||||
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
input.y:1.1-35: note: accepted value: 'most'
|
||||
input.y:1.1-35: note: accepted value: 'consistent'
|
||||
input.y:1.1-35: note: accepted value: 'accepting'
|
||||
]])
|
||||
|
||||
|
||||
# Back-end.
|
||||
AT_DATA([[input.y]],
|
||||
[[%define api.push-pull neither
|
||||
@@ -2548,7 +2613,9 @@ AT_DATA_GRAMMAR([[input.y]],
|
||||
%printer { $%; @%; } <*> exp TOK;
|
||||
%{ $ @ %} // Should not warn.
|
||||
%%
|
||||
exp: TOK { $%; @%; $$ = $1; };
|
||||
exp: TOK { $%; @%; $$ = $1; }
|
||||
| 'a' { $<->1; $$ = 1; }
|
||||
| 'b' { $<foo->bar>$; }
|
||||
%%
|
||||
$ @ // Should not warn.
|
||||
]])
|
||||
@@ -2562,6 +2629,7 @@ input.y:13.19: warning: stray '$' [-Wother]
|
||||
input.y:13.23: warning: stray '@' [-Wother]
|
||||
input.y:16.19: warning: stray '$' [-Wother]
|
||||
input.y:16.23: warning: stray '@' [-Wother]
|
||||
input.y:17.19: warning: stray '$' [-Wother]
|
||||
]])
|
||||
|
||||
AT_BISON_OPTION_POPDEFS
|
||||
|
||||
Reference in New Issue
Block a user