warnings: sort the messages by location

Sort the warnings by location (file, line number, column). They are built
using an obstack then stored in a list, and finally sorted just before
being printed, at the end.

* src/complain.c, src/complain.h: New warning struct, obstack, and
implementation
* src/location.c, location.h (location_obstack_caret,
location_obstack_print): New
* src/main.c: Print the warnings
* src/muscle-tab.c, src/reader.c, src/scan-code.l, src/symtab.c: Adapt for
multi-part warnings
* tests/actions.at, tests/conflicts.at, tests/existing.at, tests/input.at,
* tests/reduce.at, tests/regression.at, tests/skeleton.at: Update testsuite
This commit is contained in:
Valentin Tolmer
2013-08-29 14:06:12 +02:00
parent a728075710
commit 702c92a80b
16 changed files with 531 additions and 260 deletions

View File

@@ -142,15 +142,15 @@ exp: foo { $$; } foo { $2; } foo
]])
AT_BISON_CHECK([-fcaret input.y], [1], [],
[[input.y:5.12-13: error: $$ for the midrule at $2 of 'exp' has no declared type
[[input.y:5.6-32: warning: type clash on default action: <bar> != <> [-Wother]
exp: foo { $$; } foo { $2; } foo
^^^^^^^^^^^^^^^^^^^^^^^^^^^
input.y:5.12-13: error: $$ for the midrule at $2 of 'exp' has no declared type
exp: foo { $$; } foo { $2; } foo
^^
input.y:5.24-25: error: $2 of 'exp' has no declared type
exp: foo { $$; } foo { $2; } foo
^^
input.y:5.6-32: warning: type clash on default action: <bar> != <> [-Wother]
exp: foo { $$; } foo { $2; } foo
^^^^^^^^^^^^^^^^^^^^^^^^^^^
input.y:6.6-8: warning: type clash on default action: <bar> != <> [-Wother]
| foo
^^^
@@ -208,12 +208,12 @@ _AT_UNUSED_VALUES_DECLARATIONS])
AT_BISON_CHECK(m4_ifval($2, [--warnings=midrule-values ])[-fcaret input.y],
[0], [],
[[input.y:11.10-32: warning: unset value: $][$ [-Wother]
a: INT | INT { } INT { } INT { };
^^^^^^^^^^^^^^^^^^^^^^^
input.y:11.10-12: warning: unused value: $][1 [-Wother]
[[input.y:11.10-12: warning: unused value: $][1 [-Wother]
a: INT | INT { } INT { } INT { };
^^^
input.y:11.10-32: warning: unset value: $][$ [-Wother]
a: INT | INT { } INT { } INT { };
^^^^^^^^^^^^^^^^^^^^^^^
input.y:11.18-20: warning: unused value: $][3 [-Wother]
a: INT | INT { } INT { } INT { };
^^^
@@ -223,28 +223,28 @@ input.y:11.26-28: warning: unused value: $][5 [-Wother]
input.y:12.10-15: warning: empty rule for typed nonterminal, and no action [-Wother]
b: INT | %empty;
^^^^^^
input.y:13.10-62: warning: unset value: $][$ [-Wother]
c: INT | INT { $][1; } INT { $<integer>2; } INT { $<integer>4; };
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
]]m4_ifval($2, [[[input.y:13.14-20: warning: unset value: $][$ [-Wmidrule-values]
c: INT | INT { $][1; } INT { $<integer>2; } INT { $<integer>4; };
^^^^^^^
input.y:13.26-41: warning: unset value: $][$ [-Wmidrule-values]
c: INT | INT { $][1; } INT { $<integer>2; } INT { $<integer>4; };
^^^^^^^^^^^^^^^^
]]])[[input.y:13.10-62: warning: unset value: $][$ [-Wother]
c: INT | INT { $][1; } INT { $<integer>2; } INT { $<integer>4; };
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
input.y:13.22-24: warning: unused value: $][3 [-Wother]
]]])[[input.y:13.22-24: warning: unused value: $][3 [-Wother]
c: INT | INT { $][1; } INT { $<integer>2; } INT { $<integer>4; };
^^^
input.y:13.43-45: warning: unused value: $][5 [-Wother]
]]m4_ifval($2, [[[input.y:13.26-41: warning: unset value: $][$ [-Wmidrule-values]
c: INT | INT { $][1; } INT { $<integer>2; } INT { $<integer>4; };
^^^^^^^^^^^^^^^^
]]])[[input.y:13.43-45: warning: unused value: $][5 [-Wother]
c: INT | INT { $][1; } INT { $<integer>2; } INT { $<integer>4; };
^^^
input.y:14.10-49: warning: unset value: $][$ [-Wother]
d: INT | INT { } INT { $][1; } INT { $<integer>2; };
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
]]m4_ifval($2, [[[input.y:14.14-16: warning: unset value: $][$ [-Wmidrule-values]
d: INT | INT { } INT { $][1; } INT { $<integer>2; };
^^^
]]])[[input.y:14.10-49: warning: unset value: $][$ [-Wother]
d: INT | INT { } INT { $][1; } INT { $<integer>2; };
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
input.y:14.18-20: warning: unused value: $][3 [-Wother]
]]])[[input.y:14.18-20: warning: unused value: $][3 [-Wother]
d: INT | INT { } INT { $][1; } INT { $<integer>2; };
^^^
input.y:14.30-32: warning: unused value: $][5 [-Wother]
@@ -259,12 +259,12 @@ input.y:15.18-20: warning: unused value: $][3 [-Wother]
input.y:15.27-29: warning: unused value: $][5 [-Wother]
e: INT | INT { } INT { } INT { $][1; };
^^^
input.y:17.10-58: warning: unset value: $][$ [-Wother]
g: INT | INT { $<integer>$; } INT { $<integer>$; } INT { };
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
input.y:17.10-12: warning: unused value: $][1 [-Wother]
g: INT | INT { $<integer>$; } INT { $<integer>$; } INT { };
^^^
input.y:17.10-58: warning: unset value: $][$ [-Wother]
g: INT | INT { $<integer>$; } INT { $<integer>$; } INT { };
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
]]m4_ifval($2, [[[input.y:17.14-29: warning: unused value: $][2 [-Wmidrule-values]
g: INT | INT { $<integer>$; } INT { $<integer>$; } INT { };
^^^^^^^^^^^^^^^^
@@ -277,12 +277,12 @@ input.y:17.10-12: warning: unused value: $][1 [-Wother]
]]])[[input.y:17.52-54: warning: unused value: $][5 [-Wother]
g: INT | INT { $<integer>$; } INT { $<integer>$; } INT { };
^^^
input.y:18.10-72: warning: unset value: $][$ [-Wother]
h: INT | INT { $<integer>$; } INT { $<integer>$ = $<integer>2; } INT { };
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
input.y:18.10-12: warning: unused value: $][1 [-Wother]
h: INT | INT { $<integer>$; } INT { $<integer>$ = $<integer>2; } INT { };
^^^
input.y:18.10-72: warning: unset value: $][$ [-Wother]
h: INT | INT { $<integer>$; } INT { $<integer>$ = $<integer>2; } INT { };
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
input.y:18.31-33: warning: unused value: $][3 [-Wother]
h: INT | INT { $<integer>$; } INT { $<integer>$ = $<integer>2; } INT { };
^^^
@@ -295,12 +295,12 @@ input.y:18.31-33: warning: unused value: $][3 [-Wother]
]]m4_ifval($2, [[[input.y:20.18-37: warning: unused value: $][3 [-Wmidrule-values]
j: INT | INT INT { $<integer>$ = 1; } { $][$ = $][1 + $][2; };
^^^^^^^^^^^^^^^^^^^^
]]])[[input.y:21.10-68: warning: unset value: $][$ [-Wother]
k: INT | INT INT { $<integer>$; } { $<integer>$ = $<integer>3; } { };
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
input.y:21.10-12: warning: unused value: $][1 [-Wother]
]]])[[input.y:21.10-12: warning: unused value: $][1 [-Wother]
k: INT | INT INT { $<integer>$; } { $<integer>$ = $<integer>3; } { };
^^^
input.y:21.10-68: warning: unset value: $][$ [-Wother]
k: INT | INT INT { $<integer>$; } { $<integer>$ = $<integer>3; } { };
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
input.y:21.14-16: warning: unused value: $][2 [-Wother]
k: INT | INT INT { $<integer>$; } { $<integer>$ = $<integer>3; } { };
^^^
@@ -458,15 +458,15 @@ exp: bar;
]])
AT_BISON_CHECK([-fcaret input.y], [1], [],
[[input.y:2.16-18: error: symbol bar is used, but is not defined as a token and has no rules
%destructor {} bar
^^^
[[input.y:1.13-15: warning: symbol foo is used, but is not defined as a token and has no rules [-Wother]
%printer {} foo baz
^^^
input.y:1.17-19: warning: symbol baz is used, but is not defined as a token and has no rules [-Wother]
%printer {} foo baz
^^^
input.y:1.13-15: warning: symbol foo is used, but is not defined as a token and has no rules [-Wother]
%printer {} foo baz
^^^
input.y:2.16-18: error: symbol bar is used, but is not defined as a token and has no rules
%destructor {} bar
^^^
input.y:3.13-15: warning: symbol qux is used, but is not defined as a token and has no rules [-Wother]
%type <foo> qux
^^^
@@ -1417,9 +1417,9 @@ start: TOK;
AT_BISON_CHECK([[input.yy]], [0], [],
[[input.yy:2.9-25: warning: %define variable 'api.location.type' requires '{...}' values [-Wdeprecated]
input.yy:3.9-21: warning: %define variable 'api.namespace' requires '{...}' values [-Wdeprecated]
input.yy:4.9-18: warning: %define variable 'api.prefix' requires '{...}' values [-Wdeprecated]
input.yy:5.9-24: warning: %define variable 'api.token.prefix' requires '{...}' values [-Wdeprecated]
input.yy:3.9-21: warning: %define variable 'api.namespace' requires '{...}' values [-Wdeprecated]
]])
])
@@ -1448,11 +1448,11 @@ exp: %empty
]])
AT_BISON_CHECK([[input.y]], [0], [],
[[input.y:5.9-15: warning: %define variable 'lr.type' requires keyword values [-Wdeprecated]
[[input.y:1.9-16: warning: %define variable 'api.pure' requires keyword values [-Wdeprecated]
input.y:2.9-21: warning: %define variable 'api.push-pull' requires keyword values [-Wdeprecated]
input.y:3.9-28: warning: %define variable 'lr.default-reduction' requires keyword values [-Wdeprecated]
input.y:4.9-33: warning: %define variable 'lr.keep-unreachable-state' requires keyword values [-Wdeprecated]
input.y:2.9-21: warning: %define variable 'api.push-pull' requires keyword values [-Wdeprecated]
input.y:1.9-16: warning: %define variable 'api.pure' requires keyword values [-Wdeprecated]
input.y:5.9-15: warning: %define variable 'lr.type' requires keyword values [-Wdeprecated]
]])
])
@@ -1717,26 +1717,26 @@ AT_CHECK([[$PERL -e 'print "start: \"\\\t\\\f\\\0\\\1\" ;";' >> input.y \
|| exit 77]])
AT_BISON_CHECK([input.y], [1], [],
[[input.y:2.9-12: error: invalid number after \-escape: 777
input.y:2.8-13: warning: empty character literal [-Wother]
input.y:2.16-17: error: invalid number after \-escape: 0
[[input.y:2.8-13: warning: empty character literal [-Wother]
input.y:2.9-12: error: invalid number after \-escape: 777
input.y:2.15-18: warning: empty character literal [-Wother]
input.y:2.21-25: error: invalid number after \-escape: xfff
input.y:2.16-17: error: invalid number after \-escape: 0
input.y:2.20-26: warning: empty character literal [-Wother]
input.y:2.29-31: error: invalid number after \-escape: x0
input.y:2.21-25: error: invalid number after \-escape: xfff
input.y:2.28-32: warning: empty character literal [-Wother]
input.y:3.9-14: error: invalid number after \-escape: uffff
input.y:2.29-31: error: invalid number after \-escape: x0
input.y:3.8-15: warning: empty character literal [-Wother]
input.y:3.18-23: error: invalid number after \-escape: u0000
input.y:3.9-14: error: invalid number after \-escape: uffff
input.y:3.17-24: warning: empty character literal [-Wother]
input.y:3.27-36: error: invalid number after \-escape: Uffffffff
input.y:3.18-23: error: invalid number after \-escape: u0000
input.y:3.26-37: warning: empty character literal [-Wother]
input.y:3.40-49: error: invalid number after \-escape: U00000000
input.y:3.27-36: error: invalid number after \-escape: Uffffffff
input.y:3.39-50: warning: empty character literal [-Wother]
input.y:4.9-10: error: invalid character after \-escape: ' '
input.y:3.40-49: error: invalid number after \-escape: U00000000
input.y:4.8-11: warning: empty character literal [-Wother]
input.y:4.14-15: error: invalid character after \-escape: A
input.y:4.9-10: error: invalid character after \-escape: ' '
input.y:4.13-16: warning: empty character literal [-Wother]
input.y:4.14-15: error: invalid character after \-escape: A
input.y:5.9-16: error: invalid character after \-escape: \t
input.y:5.17: error: invalid character after \-escape: \f
input.y:5.18: error: invalid character after \-escape: \0
@@ -2007,12 +2007,12 @@ AT_BISON_CHECK([[input.y]], [[1]], [[]],
input.y:11.15-24: warning: deprecated directive: '%expect_rr', use '%expect-rr' [-Wdeprecated]
input.y:12.15-24: warning: deprecated directive: '%expect_rr', use '%expect-rr' [-Wdeprecated]
input.y:13.1-14: warning: deprecated directive: '%error_verbose', use '%define parse.error verbose' [-Wdeprecated]
input.y:13.16-29: warning: deprecated directive: '%error_verbose', use '%define parse.error verbose' [-Wdeprecated]
input.y:13.11-21: error: %define variable 'parse.error' redefined
input.y:13-6: previous definition
input.y:14.16-29: warning: deprecated directive: '%error_verbose', use '%define parse.error verbose' [-Wdeprecated]
input.y:13.16-29: warning: deprecated directive: '%error_verbose', use '%define parse.error verbose' [-Wdeprecated]
input.y:14.11-21: error: %define variable 'parse.error' redefined
input.y:13.11-21: previous definition
input.y:14.16-29: warning: deprecated directive: '%error_verbose', use '%define parse.error verbose' [-Wdeprecated]
]])
AT_CLEANUP