[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 12/21] yacc.c: revert to not using yysymbol_type_t in the yytrans
From: |
Akim Demaille |
Subject: |
[PATCH 12/21] yacc.c: revert to not using yysymbol_type_t in the yytranslate table |
Date: |
Wed, 1 Apr 2020 08:37:38 +0200 |
This triggers warnings with several compilers. For instance ICC fills
the logs with pages and pages of
input.c(477): error: a value of type "int" cannot be used to initialize an
entity of type "const yysymbol_type_t={yysymbol_type_t}"
0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
^
input.c(477): error: a value of type "int" cannot be used to initialize an
entity of type "const yysymbol_type_t={yysymbol_type_t}"
0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
^
And so does G++9 when compiling yacc.c's (C) output
input.c:545:8: error: invalid conversion from 'int' to 'yysymbol_type_t'
[-fpermissive]
545 | 0, 5, 9, 2, 2, 2, 2, 2, 2,
2,
| ^
| |
| int
input.c:545:15: error: invalid conversion from 'int' to 'yysymbol_type_t'
[-fpermissive]
545 | 0, 5, 9, 2, 2, 2, 2, 2, 2,
2,
| ^
| |
| int
Clang++ is no exception
input.c:545:8: error: cannot initialize an array element of type 'const
yysymbol_type_t' with an rvalue of type 'int'
0, 5, 9, 2, 2, 2, 2, 2, 2, 2,
^
input.c:545:15: error: cannot initialize an array element of type 'const
yysymbol_type_t' with an rvalue of type 'int'
0, 5, 9, 2, 2, 2, 2, 2, 2, 2,
^
At some point we could use yysymbol_type_t's enumerators to define
yytranslate. Meanwhile...
* data/skeletons/yacc.c (yytranslate): Use the original integral type
to define it.
(YYTRANSLATE): Cast the result into yysymbol_type_t.
---
data/skeletons/yacc.c | 10 ++++++----
tests/regression.at | 2 +-
2 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/data/skeletons/yacc.c b/data/skeletons/yacc.c
index d9ded757..d70362ee 100644
--- a/data/skeletons/yacc.c
+++ b/data/skeletons/yacc.c
@@ -631,13 +631,15 @@ union yyalloc
/* YYTRANSLATE(TOKEN-NUM) -- Symbol number corresponding to TOKEN-NUM
as returned by yylex, with out-of-bounds checking. */
]b4_api_token_raw_if(dnl
-[[#define YYTRANSLATE(YYX) (YYX)]],
-[[#define YYTRANSLATE(YYX) \
- (0 <= (YYX) && (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYSYMBOL_YYUNDEF)
+[[#define YYTRANSLATE(YYX) YY_CAST (yysymbol_type_t, YYX)]],
+[[#define YYTRANSLATE(YYX) \
+ (0 <= (YYX) && (YYX) <= YYMAXUTOK \
+ ? YY_CAST (yysymbol_type_t, yytranslate[YYX]) \
+ : YYSYMBOL_YYUNDEF)
/* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
as returned by yylex. */
-static const yysymbol_type_t yytranslate[] =
+static const ]b4_int_type_for([b4_translate])[ yytranslate[] =
{
]b4_translate[
};]])[
diff --git a/tests/regression.at b/tests/regression.at
index fa059248..cd79b507 100644
--- a/tests/regression.at
+++ b/tests/regression.at
@@ -665,7 +665,7 @@ AT_BISON_CHECK([-v -o input.c input.y])
[sed -n 's/ *$//;/^static const.*\[\] =/,/^}/p' input.c >tables.c]
AT_CHECK([[cat tables.c]], 0,
-[[static const yysymbol_type_t yytranslate[] =
+[[static const yytype_int8 yytranslate[] =
{
0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
--
2.26.0
- [PATCH 02/21] yacc.c: introduce an enum that defines the symbol's number, (continued)
- [PATCH 02/21] yacc.c: introduce an enum that defines the symbol's number, Akim Demaille, 2020/04/01
- [PATCH 04/21] yacc.c: use yysymbol_type_t instead of int for yytoken, Akim Demaille, 2020/04/01
- [PATCH 03/21] regen, Akim Demaille, 2020/04/01
- [PATCH 06/21] regen, Akim Demaille, 2020/04/01
- [PATCH 05/21] yacc.c: also define a symbol number for the empty token, Akim Demaille, 2020/04/01
- [PATCH 08/21] regen, Akim Demaille, 2020/04/01
- [PATCH 07/21] yacc.c: prefer YYSYMBOL_YYERROR to YYSYMBOL_error, Akim Demaille, 2020/04/01
- [PATCH 09/21] bistromathic: use symbol numbers instead of YYTRANSLATE, Akim Demaille, 2020/04/01
- [PATCH 11/21] regen, Akim Demaille, 2020/04/01
- [PATCH 10/21] yysymbol_type_t: always assign an enumerator, Akim Demaille, 2020/04/01
- [PATCH 12/21] yacc.c: revert to not using yysymbol_type_t in the yytranslate table,
Akim Demaille <=
- [PATCH 13/21] regen, Akim Demaille, 2020/04/01
- [PATCH 14/21] yacc.c: fix more errors from make maintainer-check-g++, Akim Demaille, 2020/04/01
- [PATCH 15/21] regen, Akim Demaille, 2020/04/01
- [PATCH 16/21] glr.c: use yysymbol_type_t, YYSYMBOL_YYEOF etc., Akim Demaille, 2020/04/01
- [PATCH 18/21] regen, Akim Demaille, 2020/04/01
- [PATCH 17/21] glr.c, yacc.c: propagate yysymbol_type_t, Akim Demaille, 2020/04/01
- [PATCH 19/21] glr.c: remove the yySymbol alias, Akim Demaille, 2020/04/01
- [PATCH 21/21] c++: replace symbol_number_type with symbol_type_type, Akim Demaille, 2020/04/01
- [PATCH 20/21] c++: also use symbol_type_type, Akim Demaille, 2020/04/01