[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 6/7] c++: minor fixes
From: |
Akim Demaille |
Subject: |
[PATCH 6/7] c++: minor fixes |
Date: |
Fri, 28 Feb 2020 06:32:18 +0100 |
Address compiler warnings such as
warning: declaration of 'yyla' shadows a member of 'yy::parser::context'
[-Wshadow]
* data/skeletons/lalr1.cc (context): Don't use the same names for
variables and members.
Use foo_ for private members, as in parser.
Also, use the + trick in array accesses to please ICC and provide it
with an int.
---
data/skeletons/lalr1.cc | 43 +++++++++++++++++++++--------------------
src/parse-gram.c | 4 ++--
src/parse-gram.h | 2 +-
3 files changed, 25 insertions(+), 24 deletions(-)
diff --git a/data/skeletons/lalr1.cc b/data/skeletons/lalr1.cc
index 8896a95d..91b08a12 100644
--- a/data/skeletons/lalr1.cc
+++ b/data/skeletons/lalr1.cc
@@ -236,25 +236,26 @@ m4_define([b4_shared_declarations],
]b4_token_constructor_define[
]b4_parse_error_bmatch([custom\|detailed\|verbose], [[
- class context {
- public:
- context (const ]b4_parser_class[& yyparser, symbol_type yyla)
- : yyparser (yyparser)
- , yyla (yyla)
- {}
+ class context
+ {
+ public:
+ context (const ]b4_parser_class[& yyparser, symbol_type yyla)
+ : yyparser_ (yyparser)
+ , yyla_ (yyla)
+ {}
]b4_locations_if([[
- const location_type& location () const { return yyla.location; }
+ const location_type& location () const { return yyla_.location; }
]])[
- /* Put in YYARG at most YYARGN of the expected tokens, and return the
- number of tokens stored in YYARG. If YYARG is null, return the
- number of expected tokens (guaranteed to be less than YYNTOKENS). */
- int yyexpected_tokens (int yyarg[], int yyargn) const;
+ /* Put in YYARG at most YYARGN of the expected tokens, and return the
+ number of tokens stored in YYARG. If YYARG is null, return the
+ number of expected tokens (guaranteed to be less than YYNTOKENS). */
+ int yyexpected_tokens (int yyarg[], int yyargn) const;
- int yysyntax_error_arguments (int yyarg[], int yyargn) const;
+ int yysyntax_error_arguments (int yyarg[], int yyargn) const;
- private:
- const ]b4_parser_class[& yyparser;
- symbol_type yyla;
+ private:
+ const ]b4_parser_class[& yyparser_;
+ symbol_type yyla_;
};
]])[
private:
@@ -1236,12 +1237,12 @@ b4_dollar_popdef])[]dnl
#if ]b4_api_PREFIX[DEBUG
// Execute LAC once. We don't care if it is successful, we
// only do it for the sake of debugging output.
- if (!yyparser.yy_lac_established_)
- yyparser.yy_lac_check_ (yyla.type_get ());
+ if (!yyparser_.yy_lac_established_)
+ yyparser_.yy_lac_check_ (yyla_.type_get ());
#endif
for (int yyx = 0; yyx < yyntokens_; ++yyx)
- if (yyx != yy_error_token_ && yyx != yy_undef_token_ &&
yyparser.yy_lac_check_ (yyx))
+ if (yyx != yy_error_token_ && yyx != yy_undef_token_ &&
yyparser_.yy_lac_check_ (yyx))
{
if (!yyarg)
++yycount;
@@ -1251,7 +1252,7 @@ b4_dollar_popdef])[]dnl
yyarg[yycount++] = yyx;
}
]], [[
- int yyn = yypact_[yyparser.yystack_[0].state];
+ int yyn = yypact_[+yyparser_.yystack_[0].state];
if (!yy_pact_value_is_default_ (yyn))
{
/* Start YYX at -YYN if negative to avoid negative indexes in
@@ -1311,9 +1312,9 @@ b4_dollar_popdef])[]dnl
accepted due to an error action in a later state.]])[
*/
- if (!yyla.empty ())
+ if (!yyla_.empty ())
{
- yyarg[0] = yyla.type_get ();
+ yyarg[0] = yyla_.type_get ();
int yyn = yyexpected_tokens (yyarg ? yyarg + 1 : yyarg, yyargn - 1);
return yyn + 1;
}
diff --git a/src/parse-gram.c b/src/parse-gram.c
index 0ca7a566..2d4c8a30 100644
--- a/src/parse-gram.c
+++ b/src/parse-gram.c
@@ -1,4 +1,4 @@
-/* A Bison parser, made by GNU Bison 3.5.2. */
+/* A Bison parser, made by GNU Bison 3.5.2.140-15e57-dirty. */
/* Bison implementation for Yacc-like parsers in C
@@ -48,7 +48,7 @@
#define YYBISON 1
/* Bison version. */
-#define YYBISON_VERSION "3.5.2"
+#define YYBISON_VERSION "3.5.2.140-15e57-dirty"
/* Skeleton name. */
#define YYSKELETON_NAME "yacc.c"
diff --git a/src/parse-gram.h b/src/parse-gram.h
index e07ce98b..de7fd498 100644
--- a/src/parse-gram.h
+++ b/src/parse-gram.h
@@ -1,4 +1,4 @@
-/* A Bison parser, made by GNU Bison 3.5.2. */
+/* A Bison parser, made by GNU Bison 3.5.2.140-15e57-dirty. */
/* Bison interface for Yacc-like parsers in C
--
2.25.1
- [PATCH 0/7] C++ support for custom error messages, Akim Demaille, 2020/02/28
- [PATCH 1/7] typo: succesful -> successful, Akim Demaille, 2020/02/28
- [PATCH 2/7] skeletons: prefer b4_parse_error_{case, bmatch} over manual solution, Akim Demaille, 2020/02/28
- [PATCH 3/7] c++: add support for parse.error=detailed, Akim Demaille, 2020/02/28
- [PATCH 4/7] c++: add parser::context for syntax error handling, Akim Demaille, 2020/02/28
- [PATCH 5/7] c++: add support for parse.error=custom, Akim Demaille, 2020/02/28
- [PATCH 6/7] c++: minor fixes,
Akim Demaille <=
- [PATCH 7/7] c++: don't copy the lookahead, Akim Demaille, 2020/02/28