[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 09/10] skeletons: beware not to use yyarg when it's null
From: |
Akim Demaille |
Subject: |
[PATCH 09/10] skeletons: beware not to use yyarg when it's null |
Date: |
Tue, 7 Apr 2020 07:13:56 +0200 |
Reported by Adrian Vogelsgesang.
* data/skeletons/glr.c, data/skeletons/lalr1.cc,
* data/skeletons/lalr1.java, data/skeletons/yacc.c: Here.
---
TODO | 3 ---
data/skeletons/glr.c | 4 +++-
data/skeletons/lalr1.cc | 3 ++-
data/skeletons/lalr1.java | 4 +++-
data/skeletons/yacc.c | 4 +++-
5 files changed, 11 insertions(+), 7 deletions(-)
diff --git a/TODO b/TODO
index 6d5a1480..1e589ddc 100644
--- a/TODO
+++ b/TODO
@@ -1,7 +1,4 @@
* Bison 3.6
-** syntax_error_arguments
-Don't store the lookahead if !argv.
-
** Documentation
- yyexpected_tokens in all the languages.
- YYNOMEM
diff --git a/data/skeletons/glr.c b/data/skeletons/glr.c
index f5d51bb1..c17e7208 100644
--- a/data/skeletons/glr.c
+++ b/data/skeletons/glr.c
@@ -2188,7 +2188,9 @@ yy_syntax_error_arguments (const yyGLRStack* yystackp,
if (yytoken != YYSYMBOL_YYEMPTY)
{
int yyn;
- yyarg[yycount++] = yytoken;
+ if (yyarg)
+ yyarg[yycount] = yytoken;
+ ++yycount;
yyn = yyexpected_tokens (yystackp, yyarg ? yyarg + 1 : yyarg, yyargn -
1);
if (yyn == YYNOMEM)
return YYNOMEM;
diff --git a/data/skeletons/lalr1.cc b/data/skeletons/lalr1.cc
index 104009c9..7dfb63f7 100644
--- a/data/skeletons/lalr1.cc
+++ b/data/skeletons/lalr1.cc
@@ -1458,7 +1458,8 @@ b4_dollar_popdef])[]dnl
if (!yyctx.lookahead ().empty ())
{
- yyarg[0] = yyctx.token ();
+ if (yyarg)
+ yyarg[0] = yyctx.token ();
int yyn = yyctx.yyexpected_tokens (yyarg ? yyarg + 1 : yyarg, yyargn -
1);
return yyn + 1;
}
diff --git a/data/skeletons/lalr1.java b/data/skeletons/lalr1.java
index 58957a2d..529da270 100644
--- a/data/skeletons/lalr1.java
+++ b/data/skeletons/lalr1.java
@@ -981,7 +981,9 @@ b4_dollar_popdef[]dnl
int yycount = 0;
if (yyctx.getToken () != null)
{
- yyarg[yycount++] = yyctx.getToken ();
+ if (yyarg != null)
+ yyarg[yycount] = yyctx.getToken ();
+ yycount += 1;
yycount += yyctx.getExpectedTokens (yyarg, 1, yyargn);
}
return yycount;
diff --git a/data/skeletons/yacc.c b/data/skeletons/yacc.c
index 99d99ff4..98612a73 100644
--- a/data/skeletons/yacc.c
+++ b/data/skeletons/yacc.c
@@ -1360,7 +1360,9 @@ yy_syntax_error_arguments (const yypcontext_t *yyctx,
{
int yyn;]b4_lac_if([[
YYDPRINTF ((stderr, "Constructing syntax error message\n"));]])[
- yyarg[yycount++] = yyctx->yytoken;
+ if (yyarg)
+ yyarg[yycount] = yyctx->yytoken;
+ ++yycount;
yyn = yyexpected_tokens (yyctx, yyarg ? yyarg + 1 : yyarg, yyargn - 1);
if (yyn == YYNOMEM)
return YYNOMEM;]b4_lac_if([[
--
2.26.0
- [PATCH 00/10] Make recent feature better looking, Akim Demaille, 2020/04/07
- [PATCH 01/10] c: make the generated YYSTYPE nicer to read, Akim Demaille, 2020/04/07
- [PATCH 02/10] c: make the token kind definition nicer to read, Akim Demaille, 2020/04/07
- [PATCH 03/10] c: make the symbol kind definition nicer to read, Akim Demaille, 2020/04/07
- [PATCH 05/10] java: use getExpectedTokens, not yyexpectedTokens, Akim Demaille, 2020/04/07
- [PATCH 04/10] java: style: fix coding style, Akim Demaille, 2020/04/07
- [PATCH 07/10] java: prefer null to YYSYMBOL_YYEMPTY, Akim Demaille, 2020/04/07
- [PATCH 10/10] todo: update, Akim Demaille, 2020/04/07
- [PATCH 06/10] java: rename Lexer.yyreportSyntaxError as reportSyntaxError, Akim Demaille, 2020/04/07
- [PATCH 08/10] java: document new features, Akim Demaille, 2020/04/07
- [PATCH 09/10] skeletons: beware not to use yyarg when it's null,
Akim Demaille <=