mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 12:23:04 +00:00
Currently, when we quote the source file, we indent it with one space, and preserve tabulations, so there is a discrepancy and the visual rendering is bad. One way out is to indent with a tab instead of a space, but then this space can be used for more information. This is what GCC9 does. Let's play copy cats. See https://lists.gnu.org/archive/html/bison-patches/2019-04/msg00025.html https://developers.redhat.com/blog/2019/03/08/usability-improvements-in-gcc-9/ https://gcc.gnu.org/onlinedocs/gccint/Guidelines-for-Diagnostics.html#Guidelines-for-Diagnostics * src/location.c (location_caret): Prefix quoted lines with the line number and a pipe, fitting 8 columns. * tests/actions.at, tests/c++.at, tests/conflicts.at, * tests/diagnostics.at, tests/input.at, tests/java.at, * tests/named-refs.at, tests/reduce.at, tests/regression.at, * tests/sets.at: Adjust expectations. Partly by "./build-aux/update-test tests/testsuite.dir/*/testsuite.log" repeatedly, and partly by hand.
166 lines
5.9 KiB
Plaintext
166 lines
5.9 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])
|
|
|
|
# We need UTF-8 support for correct screen-width computation of UTF-8
|
|
# characters. Skip the test if not available.
|
|
AT_SKIP_IF([! locale -a | grep '^en_US.UTF-8$'])
|
|
|
|
AT_BISON_OPTION_PUSHDEFS
|
|
|
|
AT_DATA_GRAMMAR([[input.y]], [$2])
|
|
|
|
AT_DATA([experr], [$3])
|
|
# Cannot use AT_BISON_CHECK easily as we need to change the
|
|
# environment.
|
|
# FIXME: Enhance AT_BISON_CHECK.
|
|
AT_CHECK([LC_ALL=en_US.UTF-8 bison -fcaret --style=debug -Wall input.y], [], [], [experr])
|
|
|
|
# When no style, same messages, but without style.
|
|
AT_CHECK([perl -pi -e 's{</?\w+>}{}g' experr])
|
|
AT_CHECK([LC_ALL=en_US.UTF-8 bison -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>]
|
|
9 | %token FOO <warning>FOO</warning> FOO
|
|
| <warning>^~~</warning>
|
|
input.y:9.16-18: <warning>warning:</warning> symbol FOO redeclared [<warning>-Wother</warning>]
|
|
9 | %token FOO FOO <warning>FOO</warning>
|
|
| <warning>^~~</warning>
|
|
input.y:10.8-10: <warning>warning:</warning> symbol FOO redeclared [<warning>-Wother</warning>]
|
|
10 | %token <warning>FOO</warning> FOO FOO
|
|
| <warning>^~~</warning>
|
|
input.y:10.13-15: <warning>warning:</warning> symbol FOO redeclared [<warning>-Wother</warning>]
|
|
10 | %token FOO <warning>FOO</warning> FOO
|
|
| <warning>^~~</warning>
|
|
input.y:10.18-20: <warning>warning:</warning> symbol FOO redeclared [<warning>-Wother</warning>]
|
|
10 | %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>]
|
|
11 | a: <warning>{}</warning>
|
|
| <warning>^~</warning>
|
|
input.y:12.3-13.1: <warning>warning:</warning> empty rule without %empty [<warning>-Wempty-rule</warning>]
|
|
12 | b:<warning>{</warning>
|
|
| <warning>^</warning>
|
|
input.y:14.2: <warning>warning:</warning> empty rule without %empty [<warning>-Wempty-rule</warning>]
|
|
14 | c<warning>:</warning>
|
|
| <warning>^</warning>
|
|
input.y:15.2: <warning>warning:</warning> empty rule without %empty [<warning>-Wempty-rule</warning>]
|
|
15 | d
|
|
| <warning>^</warning>
|
|
input.y:17.2: <warning>warning:</warning> empty rule without %empty [<warning>-Wempty-rule</warning>]
|
|
17 | e<warning>:</warning>
|
|
| <warning>^</warning>
|
|
]])
|
|
|
|
|
|
## -------------------------------------- ##
|
|
## Tabulations and multibyte characters. ##
|
|
## -------------------------------------- ##
|
|
|
|
# Make sure we treat tabulations as eight spaces, and that multibyte
|
|
# characters have correct width.
|
|
|
|
AT_TEST([[Tabulations and multibyte characters]],
|
|
[[%%
|
|
exp: a b c d e f g h
|
|
a: { }
|
|
b: { }
|
|
c: {------------}
|
|
d: {éééééééééééé}
|
|
e: {∇⃗×𝐸⃗ = -∂𝐵⃗/∂t}
|
|
f: { 42 }
|
|
g: { "฿¥$€₦" }
|
|
h: { 🐃 }
|
|
]],
|
|
[[input.y:11.4-17: <warning>warning:</warning> empty rule without %empty [<warning>-Wempty-rule</warning>]
|
|
11 | a: <warning>{ }</warning>
|
|
| <warning>^~~~~~~~~~~~~~</warning>
|
|
input.y:12.4-17: <warning>warning:</warning> empty rule without %empty [<warning>-Wempty-rule</warning>]
|
|
12 | b: <warning>{ }</warning>
|
|
| <warning>^~~~~~~~~~~~~~</warning>
|
|
input.y:13.4-17: <warning>warning:</warning> empty rule without %empty [<warning>-Wempty-rule</warning>]
|
|
13 | c: <warning>{------------}</warning>
|
|
| <warning>^~~~~~~~~~~~~~</warning>
|
|
input.y:14.4-17: <warning>warning:</warning> empty rule without %empty [<warning>-Wempty-rule</warning>]
|
|
14 | d: <warning>{éééééééééééé}</warning>
|
|
| <warning>^~~~~~~~~~~~~~</warning>
|
|
input.y:15.4-17: <warning>warning:</warning> empty rule without %empty [<warning>-Wempty-rule</warning>]
|
|
15 | e: <warning>{∇⃗×𝐸⃗ = -∂𝐵⃗/∂t}</warning>
|
|
| <warning>^~~~~~~~~~~~~~</warning>
|
|
input.y:16.4-17: <warning>warning:</warning> empty rule without %empty [<warning>-Wempty-rule</warning>]
|
|
16 | f: <warning>{ 42 }</warning>
|
|
| <warning>^~~~~~~~~~~~~~</warning>
|
|
input.y:17.4-17: <warning>warning:</warning> empty rule without %empty [<warning>-Wempty-rule</warning>]
|
|
17 | g: <warning>{ "฿¥$€₦" }</warning>
|
|
| <warning>^~~~~~~~~~~~~~</warning>
|
|
input.y:18.4-17: <warning>warning:</warning> empty rule without %empty [<warning>-Wempty-rule</warning>]
|
|
18 | h: <warning>{ 🐃 }</warning>
|
|
| <warning>^~~~~~~~~~~~~~</warning>
|
|
]])
|
|
|
|
|
|
|
|
m4_popdef([AT_TEST])
|