[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 07/12] diagnostics: improve accuracy for deprecated %define varia
From: |
Akim Demaille |
Subject: |
[PATCH 07/12] diagnostics: improve accuracy for deprecated %define variables |
Date: |
Sun, 13 Jan 2019 15:24:02 +0100 |
* src/parse-gram.y: Use the location of the whole definition to record
the location of a %define variable, instead of just the name of the
variable.
Adjust tests.
---
src/parse-gram.c | 6 +-
src/parse-gram.h | 2 +-
src/parse-gram.y | 2 +-
tests/input.at | 172 ++++++++++++++++++++++++-----------------------
tests/push.at | 2 +-
tests/types.at | 4 +-
6 files changed, 95 insertions(+), 93 deletions(-)
diff --git a/src/parse-gram.c b/src/parse-gram.c
index bedbc110..4b3ba4f7 100644
--- a/src/parse-gram.c
+++ b/src/parse-gram.c
@@ -1,4 +1,4 @@
-/* A Bison parser, made by GNU Bison 3.2.90. */
+/* A Bison parser, made by GNU Bison 3.2.90.11-ccb3-dirty. */
/* Bison implementation for Yacc-like parsers in C
@@ -48,7 +48,7 @@
#define YYBISON 1
/* Bison version. */
-#define YYBISON_VERSION "3.2.90"
+#define YYBISON_VERSION "3.2.90.11-ccb3-dirty"
/* Skeleton name. */
#define YYSKELETON_NAME "yacc.c"
@@ -2292,7 +2292,7 @@ yyreduce:
case 8:
#line 293 "src/parse-gram.y" /* yacc.c:1649 */
{
- muscle_percent_define_insert ((yyvsp[-1].variable), (yylsp[-1]),
(yyvsp[0].value).kind, (yyvsp[0].value).chars,
+ muscle_percent_define_insert ((yyvsp[-1].variable), (yyloc),
(yyvsp[0].value).kind, (yyvsp[0].value).chars,
MUSCLE_PERCENT_DEFINE_GRAMMAR_FILE);
}
#line 2299 "src/parse-gram.c" /* yacc.c:1649 */
diff --git a/src/parse-gram.h b/src/parse-gram.h
index 3e22a0ec..31746018 100644
--- a/src/parse-gram.h
+++ b/src/parse-gram.h
@@ -1,4 +1,4 @@
-/* A Bison parser, made by GNU Bison 3.2.90. */
+/* A Bison parser, made by GNU Bison 3.2.90.11-ccb3-dirty. */
/* Bison interface for Yacc-like parsers in C
diff --git a/src/parse-gram.y b/src/parse-gram.y
index fe0afce7..85597421 100644
--- a/src/parse-gram.y
+++ b/src/parse-gram.y
@@ -291,7 +291,7 @@ prologue_declaration:
}
| "%define" variable value
{
- muscle_percent_define_insert ($2, @2, $3.kind, $3.chars,
+ muscle_percent_define_insert ($2, @$, $3.kind, $3.chars,
MUSCLE_PERCENT_DEFINE_GRAMMAR_FILE);
}
| "%defines" { defines_flag = true; }
diff --git a/tests/input.at b/tests/input.at
index d5eec578..522eda54 100644
--- a/tests/input.at
+++ b/tests/input.at
@@ -1740,10 +1740,10 @@ start: %empty;
]])
AT_BISON_CHECK([[input-redefined.y]], [[1]], [],
-[[input-redefined.y:2.9-11: error: %define variable 'var' redefined
-input-redefined.y:1.9-11: previous definition
-input-redefined.y:3.10-12: error: %define variable 'var' redefined
-input-redefined.y:2.9-11: previous definition
+[[input-redefined.y:2.1-20: error: %define variable 'var' redefined
+input-redefined.y:1.1-20: previous definition
+input-redefined.y:3.2-21: error: %define variable 'var' redefined
+input-redefined.y:2.1-20: previous definition
]])
AT_DATA([input-unused.y],
@@ -1753,7 +1753,7 @@ start: %empty;
]])
AT_BISON_CHECK([[input-unused.y]], [[1]], [],
-[[input-unused.y:1.9-11: error: %define variable 'var' is not used
+[[input-unused.y:1.1-19: error: %define variable 'var' is not used
]])
AT_CLEANUP
@@ -1797,7 +1797,7 @@ AT_DATA([[input-dg.y]],
start: %empty;
]])
AT_BISON_CHECK([[-Dvar=cmd-d input-dg.y]], [[1]], [],
-[[input-dg.y:1.9-11: error: %define variable 'var' redefined
+[[input-dg.y:1.1-18: error: %define variable 'var' redefined
<command line>:2: previous definition
]])
@@ -1807,9 +1807,9 @@ AT_DATA([[input-dg.y]],
start: %empty;
]])
AT_BISON_CHECK([[-fcaret -Dvar=cmd-d input-dg.y]], [[1]], [],
-[[input-dg.y:1.9-11: error: %define variable 'var' redefined
+[[input-dg.y:1.1-18: error: %define variable 'var' redefined
%define var "gram"
- ^~~
+ ^~~~~~~~~~~~~~~~~~
<command line>:3: previous definition
]])
@@ -1840,7 +1840,7 @@ start: %empty;
]])
AT_BISON_CHECK([[Input.y]], [1], [],
-[[Input.y:3.9-25: error: invalid value for %define Boolean variable
'api.parser.public'
+[[Input.y:3.1-33: error: invalid value for %define Boolean variable
'api.parser.public'
]])
AT_CLEANUP
@@ -1865,15 +1865,15 @@ start: TOK;
]])
AT_BISON_CHECK([[input.yy]], [0], [],
-[[input.yy:2.9-25: warning: %define variable 'api.location.type' 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]
+[[input.yy:2.$3: warning: %define variable 'api.location.type' requires
'{...}' values [-Wdeprecated]
+input.yy:4.$3: warning: %define variable 'api.prefix' requires '{...}' values
[-Wdeprecated]
+input.yy:5.$3: warning: %define variable 'api.token.prefix' requires '{...}'
values [-Wdeprecated]
+input.yy:3.$3: warning: %define variable 'api.namespace' requires '{...}'
values [-Wdeprecated]
]])
])
-AT_TEST([], [])
-AT_TEST(["], ["])
+AT_TEST([], [], [1-30])
+AT_TEST(["], ["], [1-32])
m4_popdef([AT_TEST])
AT_CLEANUP
@@ -1897,11 +1897,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: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.1-40: warning: %define variable 'lr.type' requires keyword values
[-Wdeprecated]
+input.y:3.1-40: warning: %define variable 'lr.default-reduction' requires
keyword values [-Wdeprecated]
+input.y:4.1-40: warning: %define variable 'lr.keep-unreachable-state' requires
keyword values [-Wdeprecated]
+input.y:2.1-40: warning: %define variable 'api.push-pull' requires keyword
values [-Wdeprecated]
+input.y:1.1-38: warning: %define variable 'api.pure' requires keyword values
[-Wdeprecated]
]])
])
@@ -1929,12 +1929,12 @@ AT_DATA([[input.y]],
start: %empty;
]])
AT_BISON_CHECK([[-fcaret input.y]], [[1]], [[]],
-[[input.y:1.9-28: error: invalid value for %define variable
'lr.default-reduction': 'bogus'
+[[input.y:1.1-34: error: invalid value for %define variable
'lr.default-reduction': 'bogus'
%define lr.default-reduction bogus
- ^~~~~~~~~~~~~~~~~~~~
-input.y:1.9-28: accepted value: 'most'
-input.y:1.9-28: accepted value: 'consistent'
-input.y:1.9-28: accepted value: 'accepting'
+ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+input.y:1.1-34: accepted value: 'most'
+input.y:1.1-34: accepted value: 'consistent'
+input.y:1.1-34: accepted value: 'accepting'
]])
# Back-end.
@@ -1944,12 +1944,12 @@ AT_DATA([[input.y]],
start: %empty;
]])
AT_BISON_CHECK([[-fcaret input.y]], [[1]], [[]],
-[[input.y:1.9-21: error: invalid value for %define variable 'api.push-pull':
'neither'
+[[input.y:1.1-29: error: invalid value for %define variable 'api.push-pull':
'neither'
%define api.push-pull neither
- ^~~~~~~~~~~~~
-input.y:1.9-21: accepted value: 'pull'
-input.y:1.9-21: accepted value: 'push'
-input.y:1.9-21: accepted value: 'both'
+ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+input.y:1.1-29: accepted value: 'pull'
+input.y:1.1-29: accepted value: 'push'
+input.y:1.1-29: accepted value: 'both'
]])
AT_CLEANUP
@@ -1970,9 +1970,9 @@ AT_DATA([[input.y]],
start: %empty;
]])
AT_BISON_CHECK([[-fcaret input.y]], [[1]], [[]],
-[[input.y:3.9-25: error: %define variable 'api.location.file' requires 'none'
or '"..."' values
+[[input.y:3.1-33: error: %define variable 'api.location.file' requires 'none'
or '"..."' values
%define api.location.file {bogus}
- ^~~~~~~~~~~~~~~~~
+ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
]])
AT_CLEANUP
@@ -1996,27 +1996,27 @@ AT_DATA([[input.y]],
start: %empty;
]])
AT_BISON_CHECK([[-fcaret input.y]], [1], [],
-[[input.y:1.9-21: warning: deprecated directive, use '%define api.push-pull
both' [-Wdeprecated]
+[[input.y:1.1-26: warning: deprecated directive, use '%define api.push-pull
both' [-Wdeprecated]
%define api.push_pull both
- ^~~~~~~~~~~~~
-input.y:2.9-34: warning: deprecated directive, use '%define
lr.keep-unreachable-state maybe' [-Wdeprecated]
+ ^~~~~~~~~~~~~~~~~~~~~~~~~~
+input.y:2.1-40: warning: deprecated directive, use '%define
lr.keep-unreachable-state maybe' [-Wdeprecated]
%define lr.keep_unreachable_states maybe
- ^~~~~~~~~~~~~~~~~~~~~~~~~~
-input.y:3.9-17: warning: deprecated directive, use '%define api.namespace
{foo}' [-Wdeprecated]
+ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+input.y:3.1-23: warning: deprecated directive, use '%define api.namespace
{foo}' [-Wdeprecated]
%define namespace "foo"
- ^~~~~~~~~
-input.y:4.9-21: error: %define variable 'api.namespace' redefined
+ ^~~~~~~~~~~~~~~~~~~~~~~
+input.y:4.1-27: error: %define variable 'api.namespace' redefined
%define api.namespace {foo}
- ^~~~~~~~~~~~~
-input.y:3.9-17: previous definition
+ ^~~~~~~~~~~~~~~~~~~~~~~~~~~
+input.y:3.1-23: previous definition
%define namespace "foo"
- ^~~~~~~~~
-input.y:5.9-15: warning: deprecated directive, use '%define api.value.type
variant' [-Wdeprecated]
+ ^~~~~~~~~~~~~~~~~~~~~~~
+input.y:5.1-15: warning: deprecated directive, use '%define api.value.type
variant' [-Wdeprecated]
%define variant
- ^~~~~~~
-input.y:6.9-25: warning: deprecated directive, use '%define api.parser.class
{parser}' [-Wdeprecated]
+ ^~~~~~~~~~~~~~~
+input.y:6.1-34: warning: deprecated directive, use '%define api.parser.class
{parser}' [-Wdeprecated]
%define parser_class_name {parser}
- ^~~~~~~~~~~~~~~~~
+ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
]])
AT_CLEANUP
@@ -2028,11 +2028,11 @@ AT_CLEANUP
AT_SETUP([[Unused %define api.pure]])
-# AT_CHECK_API_PURE(DECLS, VALUE)
+# AT_TEST(DECLS, VALUE, LOCATION)
# -------------------------------
# Make sure Bison reports that '%define api.pure VALUE' is unused when DECLS
# are specified.
-m4_define([AT_CHECK_API_PURE],
+m4_pushdef([AT_TEST],
[
AT_DATA([[input.y]],
[[%define api.pure ]$2[
@@ -2042,16 +2042,18 @@ start: %empty;
]])
AT_BISON_CHECK([[input.y]], [[1]], [],
-[[input.y:1.9-16: error: %define variable 'api.pure' is not used
+[[input.y:]$3[: error: %define variable 'api.pure' is not used
]])
])
-AT_CHECK_API_PURE([[%language "c++"]], [[]])
-AT_CHECK_API_PURE([[%language "c++"]], [[false]])
-AT_CHECK_API_PURE([[%language "c++" %glr-parser]], [[""]])
-AT_CHECK_API_PURE([[%language "c++" %glr-parser]], [[false]])
-AT_CHECK_API_PURE([[%language "java"]], [[true]])
-AT_CHECK_API_PURE([[%language "java"]], [[false]])
+AT_TEST([[%language "c++"]], [[]], [[1.1-16]])
+AT_TEST([[%language "c++"]], [[false]], [[1.1-22]])
+AT_TEST([[%language "c++" %glr-parser]], [[""]], [[1.1-19]])
+AT_TEST([[%language "c++" %glr-parser]], [[false]], [[1.1-22]])
+AT_TEST([[%language "java"]], [[true]], [[1.1-21]])
+AT_TEST([[%language "java"]], [[false]], [[1.1-22]])
+
+m4_popdef([AT_TEST])
AT_CLEANUP
@@ -2077,31 +2079,31 @@ start: %empty;
AT_BISON_CHECK([[input.y]], [1], [],
[m4_foreach([b4_arg], m4_dquote(m4_shift($@)),
-[[input.y:3.9-21: error: ]b4_arg[
-]])])
+[b4_arg
+])])
])
AT_CHECK_NAMESPACE_ERROR([[]],
- [[namespace reference is empty]])
+ [[input.y:3.1-24: error: namespace reference is
empty]])
AT_CHECK_NAMESPACE_ERROR([[ @tb@@tb@ @tb@ @address@hidden,
- [[namespace reference is empty]])
+ [[input.y:3.1-57: error: namespace reference is
empty]])
AT_CHECK_NAMESPACE_ERROR([[foo::::bar]],
- [[namespace reference has consecutive "::"]])
+ [[input.y:3.1-34: error: namespace reference has
consecutive "::"]])
AT_CHECK_NAMESPACE_ERROR([[foo:: @tb@::bar]],
- [[namespace reference has consecutive "::"]])
+ [[input.y:3.1-38: error: namespace reference has
consecutive "::"]])
AT_CHECK_NAMESPACE_ERROR([[::::bar]],
- [[namespace reference has consecutive "::"]])
+ [[input.y:3.1-31: error: namespace reference has
consecutive "::"]])
AT_CHECK_NAMESPACE_ERROR([[:: ::bar]],
- [[namespace reference has consecutive "::"]])
+ [[input.y:3.1-32: error: namespace reference has
consecutive "::"]])
AT_CHECK_NAMESPACE_ERROR([[foo::bar::@tb@::]],
- [[namespace reference has consecutive "::"]],
- [[namespace reference has a trailing "::"]])
+ [[input.y:3.1-43: error: namespace reference has
consecutive "::"]],
+ [[input.y:3.1-43: error: namespace reference has a
trailing "::"]])
AT_CHECK_NAMESPACE_ERROR([[foo::bar::]],
- [[namespace reference has a trailing "::"]])
+ [[input.y:3.1-34: error: namespace reference has a
trailing "::"]])
AT_CHECK_NAMESPACE_ERROR([[foo::bar:: @address@hidden,
- [[namespace reference has a trailing "::"]])
+ [[input.y:3.1-41: error: namespace reference has a
trailing "::"]])
AT_CHECK_NAMESPACE_ERROR([[::]],
- [[namespace reference has a trailing "::"]])
+ [[input.y:3.1-26: error: namespace reference has a
trailing "::"]])
AT_CLEANUP
@@ -2315,10 +2317,10 @@ AT_BISON_CHECK([[$2 -Wno-deprecated input.y]], [[1]],
[[]],
]])
])
-AT_TEST([%define api.prefix {foo} %name-prefix "bar"], [], [input.y:1.9-18])
-AT_TEST([], [-Dapi.prefix={foo} -p bar], [<command line>:2])
-AT_TEST([%name-prefix "bar"], [-Dapi.prefix={foo}], [<command line>:2])
-AT_TEST([%define api.prefix {foo}], [-p bar], [input.y:1.9-18])
+AT_TEST([%define api.prefix {foo} %name-prefix "bar"], [], [input.y:1.1-24])
+AT_TEST([], [-Dapi.prefix={foo} -p bar], [<command line>:2])
+AT_TEST([%name-prefix "bar"], [-Dapi.prefix={foo}], [<command line>:2])
+AT_TEST([%define api.prefix {foo}], [-p bar], [input.y:1.1-24])
m4_popdef([AT_TEST])
@@ -2350,18 +2352,18 @@ AT_TEST([[%union foo {};
%define api.value.union.name foo]],
[[input.y:3.8-10: error: %define variable 'api.value.union.name' redefined
input.y:1.8-10: previous definition
-input.y:4.9-28: error: %define variable 'api.value.union.name' redefined
+input.y:4.1-32: error: %define variable 'api.value.union.name' redefined
input.y:3.8-10: previous definition
]])
AT_TEST([[%define api.value.union.name {foo}]],
-[[input.y:1.9-28: error: %define variable 'api.value.union.name' requires
keyword values
-input.y:1.9-28: error: %define variable 'api.value.union.name' is not used
+[[input.y:1.1-34: error: %define variable 'api.value.union.name' requires
keyword values
+input.y:1.1-34: error: %define variable 'api.value.union.name' is not used
]])
AT_TEST([[%define api.value.union.name "foo"]],
-[[input.y:1.9-28: error: %define variable 'api.value.union.name' requires
keyword values
-input.y:1.9-28: error: %define variable 'api.value.union.name' is not used
+[[input.y:1.1-34: error: %define variable 'api.value.union.name' requires
keyword values
+input.y:1.1-34: error: %define variable 'api.value.union.name' is not used
]])
m4_popdef([AT_TEST])
@@ -2522,8 +2524,8 @@ input.y:24.1-9: warning: deprecated directive: '%output
=', use '%output' [-Wdep
input.y:25.1-12: warning: deprecated directive: '%pure_parser', use
'%pure-parser' [-Wdeprecated]
input.y:26.1-12: warning: deprecated directive: '%token_table', use
'%token-table' [-Wdeprecated]
input.y:27.1-14: warning: deprecated directive: '%error-verbose', use '%define
parse.error verbose' [-Wdeprecated]
-input.y:27-6: error: %define variable 'parse.error' redefined
-input.y:11-6: previous definition
+input.y:27-14: error: %define variable 'parse.error' redefined
+input.y:11-14: previous definition
input.y:29.1-18: warning: deprecated directive: '%name-prefix "bar"', use
'%define api.prefix {bar}' [-Wdeprecated]
]])
@@ -2558,8 +2560,8 @@ input.y:26.1-12: warning: deprecated directive:
'%token_table', use '%token-tabl
fix-it:"input.y":{26:1-26:13}:"%token-table"
input.y:27.1-14: warning: deprecated directive: '%error-verbose', use '%define
parse.error verbose' [-Wdeprecated]
fix-it:"input.y":{27:1-27:15}:"%define parse.error verbose"
-input.y:27-6: error: %define variable 'parse.error' redefined
-input.y:11-6: previous definition
+input.y:27-14: error: %define variable 'parse.error' redefined
+input.y:11-14: previous definition
input.y:29.1-18: warning: deprecated directive: '%name-prefix "bar"', use
'%define api.prefix {bar}' [-Wdeprecated]
fix-it:"input.y":{29:1-29:19}:"%define api.prefix {bar}"
]])
@@ -2596,11 +2598,11 @@ input.y:11.15-24: warning: deprecated directive:
'%expect_rr', use '%expect-rr'
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:13.3-29: error: %define variable 'parse.error' redefined
+input.y:13-14: previous definition
input.y:14.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.3-29: error: %define variable 'parse.error' redefined
+input.y:13.3-29: previous definition
]])
AT_CLEANUP
diff --git a/tests/push.at b/tests/push.at
index a46c255e..72766084 100644
--- a/tests/push.at
+++ b/tests/push.at
@@ -154,7 +154,7 @@ start: ;
AT_BISON_OPTION_POPDEFS
AT_BISON_CHECK([[input.y]], [[1]], [],
-[[input.y:2.9-21: error: %define variable 'api.push-pull' is not used
+[[input.y:2.1-26: error: %define variable 'api.push-pull' is not used
]])
AT_CLEANUP
diff --git a/tests/types.at b/tests/types.at
index 8fff4291..2794838a 100644
--- a/tests/types.at
+++ b/tests/types.at
@@ -32,7 +32,7 @@ exp: %empty;
]])
AT_BISON_CHECK([[input.y]], [[1]], [[]],
-[[input.y:2.9-22: error: '%union' and '%define api.value.type' cannot be used
together
+[[input.y:2.1-38: error: '%union' and '%define api.value.type' cannot be used
together
]])
AT_CLEANUP
@@ -51,7 +51,7 @@ exp: %empty;
]])
AT_BISON_CHECK([[input.y]], [[1]], [[]],
-[[input.y:2.9-22: error: '%yacc' and '%define api.value.type "union"' cannot
be used together
+[[input.y:2.1-28: error: '%yacc' and '%define api.value.type "union"' cannot
be used together
]])
AT_CLEANUP
--
2.20.1
- [PATCH 00/12] RFC: fixits and --update, Akim Demaille, 2019/01/13
- [PATCH 12/12] diagnostics: add fixit support for duplicate removal, Akim Demaille, 2019/01/13
- [PATCH 01/12] diagnostics: style: avoid allocating memory when not needed, Akim Demaille, 2019/01/13
- [PATCH 02/12] diagnostics: improve them for %name-prefix, Akim Demaille, 2019/01/13
- [PATCH 09/12] diagnostics: avoid duplicate warnings for deprecated directives, Akim Demaille, 2019/01/13
- [PATCH 10/12] diagnostics: improve the accuracy for %error-verbose, Akim Demaille, 2019/01/13
- [PATCH 06/12] diagnostics: keep the fixits, Akim Demaille, 2019/01/13
- [PATCH 04/12] diagnostics: prefer ^~~~ to ^^^^ to underline code, Akim Demaille, 2019/01/13
- [PATCH 05/12] diagnostics: add -ffixit support for deprecated features, Akim Demaille, 2019/01/13
- [PATCH 08/12] diagnostics: update the grammar file, Akim Demaille, 2019/01/13
- [PATCH 07/12] diagnostics: improve accuracy for deprecated %define variables,
Akim Demaille <=