summaryrefslogtreecommitdiff
path: root/tests/diagnostics.at
diff options
context:
space:
mode:
authorAkim Demaille <akim.demaille@gmail.com>2019-02-16 08:01:34 +0100
committerAkim Demaille <akim.demaille@gmail.com>2019-10-06 08:07:57 +0200
commit0b585c49aef303159bf48295a1ab9f391e593072 (patch)
tree11c6aa122b8004bb1c9c008cf1a23223f7b0ede5 /tests/diagnostics.at
parent37c4d0b1753c4e562a8c761adb816c27db861494 (diff)
downloadbison-0b585c49aef303159bf48295a1ab9f391e593072.tar.gz
diagnostics: display suggested update after the caret-info
This commit adds the suggestion in green, on the line below the caret-and-tildes. foo.y:1.1-14: warning: deprecated directive: '%error-verbose', use '%define parse.error verbose' [-Wdeprecated] 1 | %error-verbose | ^~~~~~~~~~~~~~ | %define parse.error verbose The current approach, with location_caret_suggestion, is fragile: there's a protocol of calls to the complain functions which is strict. We should rather have a richer structure describing the diagnostics, including with submessages such as the suggestions, passed in the end to the routines in charge of formatting and printing them. * src/location.h, src/location.c (location_caret_suggestion): New. * src/complain.c (deprecated_directive): Use it. * tests/diagnostics.at, tests/input.at: Adjust expectations.
Diffstat (limited to 'tests/diagnostics.at')
-rw-r--r--tests/diagnostics.at24
1 files changed, 22 insertions, 2 deletions
diff --git a/tests/diagnostics.at b/tests/diagnostics.at
index 03960d5f..4042a815 100644
--- a/tests/diagnostics.at
+++ b/tests/diagnostics.at
@@ -318,6 +318,7 @@ input.y: <warning>warning:</warning> fix-its can be applied. Rerun with option
AT_TEST([[Screen width: 200 columns]],
[[%token ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ
+ %error-verbose
%%
exp: ABCDEFGHIJKLMNOPQRSTUVWXYZ
]],
@@ -340,11 +341,17 @@ input.y:9.92-117: <warning>warning:</warning> symbol ABCDEFGHIJKLMNOPQRSTUVWXYZ
input.y:9.8-33: previous declaration
9 | %token <note>ABCDEFGHIJKLMNOPQRSTUVWXYZ</note> ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ
| <note>^~~~~~~~~~~~~~~~~~~~~~~~~~</note>
+input.y:10.56-69: <warning>warning:</warning> deprecated directive: '%error-verbose', use '%define parse.error verbose' [<warning>-Wdeprecated</warning>]
+ 10 | <warning>%error-verbose</warning>
+ | <warning>^~~~~~~~~~~~~~</warning>
+ | <insertion>%define parse.error verbose</insertion>
+input.y: <warning>warning:</warning> fix-its can be applied. Rerun with option '--update'. [<warning>-Wother</warning>]
]],
[[COLUMNS=200]])
AT_TEST([[Screen width: 80 columns]],
[[%token ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ
+ %error-verbose
%%
exp: ABCDEFGHIJKLMNOPQRSTUVWXYZ
]],
@@ -367,11 +374,17 @@ input.y:9.92-117: <warning>warning:</warning> symbol ABCDEFGHIJKLMNOPQRSTUVWXYZ
input.y:9.8-33: previous declaration
9 | %token <note>ABCDEFGHIJKLMNOPQRSTUVWXYZ</note> ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEF...
| <note>^~~~~~~~~~~~~~~~~~~~~~~~~~</note>
+input.y:10.56-69: <warning>warning:</warning> deprecated directive: '%error-verbose', use '%define parse.error verbose' [<warning>-Wdeprecated</warning>]
+ 10 | <warning>%error-verbose</warning>
+ | <warning>^~~~~~~~~~~~~~</warning>
+ | <insertion>%define parse.error verbose</insertion>
+input.y: <warning>warning:</warning> fix-its can be applied. Rerun with option '--update'. [<warning>-Wother</warning>]
]],
[[COLUMNS=80]])
AT_TEST([[Screen width: 60 columns]],
[[%token ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ
+ %error-verbose
%%
exp: ABCDEFGHIJKLMNOPQRSTUVWXYZ
]],
@@ -394,6 +407,11 @@ input.y:9.92-117: <warning>warning:</warning> symbol ABCDEFGHIJKLMNOPQRSTUVWXYZ
input.y:9.8-33: previous declaration
9 | %token <note>ABCDEFGHIJKLMNOPQRSTUVWXYZ</note> ABCDEFGHIJKLMN...
| <note>^~~~~~~~~~~~~~~~~~~~~~~~~~</note>
+input.y:10.56-69: <warning>warning:</warning> deprecated directive: '%error-verbose', use '%define parse.error verbose' [<warning>-Wdeprecated</warning>]
+ 10 | ... <warning>%error-verbose</warning>
+ | <warning>^~~~~~~~~~~~~~</warning>
+ | <insertion>%define parse.error verbose</insertion>
+input.y: <warning>warning:</warning> fix-its can be applied. Rerun with option '--update'. [<warning>-Wother</warning>]
]],
[[COLUMNS=60]])
@@ -419,12 +437,14 @@ exp : '0'
]])
AT_BISON_CHECK([[-fcaret -Wno-other input.y]], [0], [],
-[[input.y:2.1-12: warning: deprecated directive, use '%define api.pure' [-Wdeprecated]
+[[input.y:2.1-12: warning: deprecated directive: '%pure-parser', use '%define api.pure' [-Wdeprecated]
2 | %pure-parser
| ^~~~~~~~~~~~
-input.y:3.1-14: warning: deprecated directive, use '%define parse.error verbose' [-Wdeprecated]
+ | %define api.pure
+input.y:3.1-14: warning: deprecated directive: '%error-verbose', use '%define parse.error verbose' [-Wdeprecated]
3 | %error-verbose
| ^~~~~~~~~~~~~~
+ | %define parse.error verbose
]])
AT_CLEANUP