mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 12:23:04 +00:00
Single point locations (equal boundaries) are troublesome, and we were incorrectly ending the style in their case. Which results in an abort in libtextstyle. There is also a confusion between columns as displayed on the screen (which take into account multibyte characters and tabulations), and the number of bytes. Counting the screen-column incrementally (character by character) is uneasy (because of multibyte characters), and I don't want to maintain a buffer of the current line when displaying the diagnostic. So I believe the simplest solution is to track the byte number in addition to the screen column. * src/location.h, src/location.c (boundary): Add the byte-column. Adjust dependencies. * src/getargs.c, src/scan-gram.l: Adjust. * tests/diagnostics.at: Check zero-width locations.
110 lines
3.4 KiB
Plaintext
110 lines
3.4 KiB
Plaintext
# Checking diagnotics. -*- Autotest -*-
|
|
|
|
# Copyright (C) 2019 Free Software Foundation, Inc.
|
|
|
|
# This program is free software: you can redistribute it and/or modify
|
|
# it under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
# (at your option) any later version.
|
|
#
|
|
# This program is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU General Public License
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
AT_BANNER([[Diagnostics.]])
|
|
|
|
# AT_TEST([TITLE], [GRAMMAR], [OUTPUT-WITH-STYLE])
|
|
m4_pushdef([AT_TEST],
|
|
[
|
|
AT_SETUP([$1])
|
|
AT_KEYWORDS([diagnostics])
|
|
|
|
AT_BISON_OPTION_PUSHDEFS
|
|
|
|
AT_DATA_GRAMMAR([[input.y]], [$2])
|
|
|
|
AT_DATA([experr], [$3])
|
|
AT_BISON_CHECK([-fcaret --style=debug -Wall input.y], [], [], [experr])
|
|
|
|
# When no style, same messages, except the style.
|
|
AT_CHECK([perl -pi -e 's{</?\w+>}{}g' experr])
|
|
AT_BISON_CHECK([-fcaret -Wall input.y], [], [], [experr])
|
|
|
|
AT_BISON_OPTION_POPDEFS
|
|
|
|
AT_CLEANUP
|
|
])
|
|
|
|
|
|
## ---------- ##
|
|
## Warnings. ##
|
|
## ---------- ##
|
|
|
|
AT_TEST([[Warnings]],
|
|
[[%token FOO FOO FOO
|
|
%token FOO FOO FOO
|
|
%%
|
|
exp: %empty;
|
|
]],
|
|
[[input.y:9.12-14: <warning>warning:</warning> symbol FOO redeclared [<warning>-Wother</warning>]
|
|
%token FOO <warning>FOO</warning> FOO
|
|
<warning>^~~</warning>
|
|
input.y:9.16-18: <warning>warning:</warning> symbol FOO redeclared [<warning>-Wother</warning>]
|
|
%token FOO FOO <warning>FOO</warning>
|
|
<warning>^~~</warning>
|
|
input.y:10.8-10: <warning>warning:</warning> symbol FOO redeclared [<warning>-Wother</warning>]
|
|
%token <warning>FOO</warning> FOO FOO
|
|
<warning>^~~</warning>
|
|
input.y:10.13-15: <warning>warning:</warning> symbol FOO redeclared [<warning>-Wother</warning>]
|
|
%token FOO <warning>FOO</warning> FOO
|
|
<warning>^~~</warning>
|
|
input.y:10.18-20: <warning>warning:</warning> symbol FOO redeclared [<warning>-Wother</warning>]
|
|
%token FOO FOO <warning>FOO</warning>
|
|
<warning>^~~</warning>
|
|
]])
|
|
|
|
|
|
## ------------------------ ##
|
|
## Single point locations. ##
|
|
## ------------------------ ##
|
|
|
|
# Single point locations (equal boundaries) are troublesome: it's easy
|
|
# to mess up the opening/closing of style. They come from the parser,
|
|
# rules with empty rhs. Their position is therefore debatable
|
|
# (between the previous token and the next one).
|
|
|
|
AT_TEST([[Single point locations]],
|
|
[[%%
|
|
exp: a b c d e
|
|
a: {}
|
|
b:{
|
|
};
|
|
c:
|
|
d
|
|
:
|
|
e:
|
|
]],
|
|
[[input.y:11.4-5: <warning>warning:</warning> empty rule without %empty [<warning>-Wempty-rule</warning>]
|
|
a: <warning>{}</warning>
|
|
<warning>^~</warning>
|
|
input.y:12.3-13.1: <warning>warning:</warning> empty rule without %empty [<warning>-Wempty-rule</warning>]
|
|
b:<warning>{</warning>
|
|
<warning>^</warning>
|
|
input.y:14.2: <warning>warning:</warning> empty rule without %empty [<warning>-Wempty-rule</warning>]
|
|
c<warning>:</warning>
|
|
<warning>^</warning>
|
|
input.y:15.2: <warning>warning:</warning> empty rule without %empty [<warning>-Wempty-rule</warning>]
|
|
d
|
|
<warning>^</warning>
|
|
input.y:17.2: <warning>warning:</warning> empty rule without %empty [<warning>-Wempty-rule</warning>]
|
|
e<warning>:</warning>
|
|
<warning>^</warning>
|
|
]])
|
|
|
|
|
|
|
|
m4_popdef([AT_TEST]) |