code: be robust to reference with invalid tags

Because we want to support $<a->b>$, we must accept -> in type tags,
and reject $<->$, as it is unfinished.
Reported by Ahcheong Lee.

* src/scan-code.l (yylex): Make sure "tag" does not end with -, since
-> does not close the tag.
* tests/input.at (Stray $ or @): Check this.
This commit is contained in:
Akim Demaille
2020-03-06 17:29:26 +01:00
parent 192e9fdf77
commit 641e326303
3 changed files with 7 additions and 3 deletions
+2 -1
View File
@@ -4,8 +4,9 @@ it is today without the invaluable help of these people:
Aaro Koskinen [email protected] Aaro Koskinen [email protected]
Аскар Сафин [email protected] Аскар Сафин [email protected]
Adam Sampson [email protected] Adam Sampson [email protected]
Ahcheong Lee [email protected]
Airy Andre [email protected] Airy Andre [email protected]
Akim Demaille akim@lrde.epita.fr Akim Demaille akim@gnu.org
Albert Chin-A-Young [email protected] Albert Chin-A-Young [email protected]
Alexander Belopolsky [email protected] Alexander Belopolsky [email protected]
Alexandre Duret-Lutz [email protected] Alexandre Duret-Lutz [email protected]
+1 -1
View File
@@ -81,7 +81,7 @@ static bool untyped_var_seen;
historically almost any character is allowed in a tag. We disallow historically almost any character is allowed in a tag. We disallow
NUL and newline, as this simplifies our implementation. We allow NUL and newline, as this simplifies our implementation. We allow
"->" as a means to dereference a pointer. */ "->" as a means to dereference a pointer. */
tag ([^\0\n>]|->)+ tag ([^\0\n>]|->)*[^-]
/* Zero or more instances of backslash-newline. Following GCC, allow /* Zero or more instances of backslash-newline. Following GCC, allow
white space between the backslash and the newline. */ white space between the backslash and the newline. */
+4 -1
View File
@@ -2548,7 +2548,9 @@ AT_DATA_GRAMMAR([[input.y]],
%printer { $%; @%; } <*> exp TOK; %printer { $%; @%; } <*> exp TOK;
%{ $ @ %} // Should not warn. %{ $ @ %} // Should not warn.
%% %%
exp: TOK { $%; @%; $$ = $1; }; exp: TOK { $%; @%; $$ = $1; }
| 'a' { $<->1; $$ = 1; }
| 'b' { $<foo->bar>$; }
%% %%
$ @ // Should not warn. $ @ // Should not warn.
]]) ]])
@@ -2562,6 +2564,7 @@ input.y:13.19: warning: stray '$' [-Wother]
input.y:13.23: warning: stray '@' [-Wother] input.y:13.23: warning: stray '@' [-Wother]
input.y:16.19: warning: stray '$' [-Wother] input.y:16.19: warning: stray '$' [-Wother]
input.y:16.23: warning: stray '@' [-Wother] input.y:16.23: warning: stray '@' [-Wother]
input.y:17.19: warning: stray '$' [-Wother]
]]) ]])
AT_BISON_OPTION_POPDEFS AT_BISON_OPTION_POPDEFS