mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 12:23:04 +00:00
tests: be strict about types
* tests/actions.at, tests/c++.at, tests/cxx-type.at, * tests/glr-regression.at, tests/local.at, tests/torture.at, * tests/types.at: Pay stricter attention to types to avoid warnings.
This commit is contained in:
@@ -691,13 +691,13 @@ const char *source = YY_NULLPTR;
|
||||
static
|
||||
]AT_YYLEX_PROTOTYPE[
|
||||
{
|
||||
static unsigned counter = 0;
|
||||
static int counter = 0;
|
||||
|
||||
unsigned c = ]AT_VAL[]m4_ifval([$6], [.ival])[ = counter++;
|
||||
int c = ]AT_VAL[]m4_ifval([$6], [.ival])[ = counter++;
|
||||
/* As in BASIC, line numbers go from 10 to 10. */
|
||||
]AT_LOC_FIRST_LINE[ = ]AT_LOC_FIRST_COLUMN[ = 10 * c;
|
||||
]AT_LOC_FIRST_LINE[ = ]AT_LOC_FIRST_COLUMN[ = ]AT_CXX_IF([(unsigned)], [(int)])[(10 * c);
|
||||
]AT_LOC_LAST_LINE[ = ]AT_LOC_LAST_COLUMN[ = ]AT_LOC_FIRST_LINE[ + 9;
|
||||
assert (c <= strlen (source));
|
||||
assert (c <= (int) strlen (source));
|
||||
if (source[c])
|
||||
fprintf (stderr, "sending: '%c'", source[c]);
|
||||
else
|
||||
@@ -1684,7 +1684,7 @@ AT_DATA_GRAMMAR([[input.y]],
|
||||
%initial-action
|
||||
{
|
||||
$<ival>$ = 42;
|
||||
$<fval>$ = 4.2;
|
||||
$<fval>$ = 4.2f;
|
||||
}
|
||||
|
||||
%%
|
||||
@@ -1699,7 +1699,7 @@ float: UNTYPED INT
|
||||
yy::parser::token::INT,
|
||||
EOF}]],
|
||||
[[{UNTYPED, INT, EOF}]]),
|
||||
[AT_VAL.ival = toknum * 10; AT_VAL.fval = toknum / 10.0;])[
|
||||
[AT_VAL.ival = (int) toknum * 10; AT_VAL.fval = (float) toknum / 10.0f;])[
|
||||
]AT_MAIN_DEFINE[
|
||||
]])
|
||||
|
||||
@@ -1816,7 +1816,7 @@ exp:
|
||||
|
||||
%%
|
||||
]AT_YYERROR_DEFINE[
|
||||
]AT_YYLEX_DEFINE(["bcd"], [*lvalp = (toknum + 1) * 10])[
|
||||
]AT_YYLEX_DEFINE(["bcd"], [*lvalp = (int) ((toknum + 1) * 10)])[
|
||||
]AT_MAIN_DEFINE[
|
||||
]])
|
||||
AT_BISON_OPTION_POPDEFS
|
||||
|
||||
@@ -1181,12 +1181,12 @@ yylex (yy::parser::semantic_type *lvalp)
|
||||
// 'R': call YYERROR in the action
|
||||
// 's': reduction throws.
|
||||
// 'T': call YYABORT in the action
|
||||
switch (int res = *input++)
|
||||
switch (char res = *input++)
|
||||
{
|
||||
case 'l':
|
||||
throw std::runtime_error ("yylex");
|
||||
default:
|
||||
lvalp->]AT_VARIANT_IF([build (Object (res))],
|
||||
lvalp->]AT_VARIANT_IF([build<Object> (res)],
|
||||
[obj = new Object (res)])[;
|
||||
// Fall through.
|
||||
case 0:
|
||||
|
||||
@@ -137,9 +137,6 @@ main (int argc, char **argv)
|
||||
|
||||
]AT_YYLEX_PROTOTYPE[
|
||||
{
|
||||
char buffer[256];
|
||||
int c;
|
||||
unsigned i;
|
||||
static int lineNum = 1;
|
||||
static int colNum = 0;
|
||||
|
||||
@@ -152,6 +149,7 @@ main (int argc, char **argv)
|
||||
|
||||
while (1)
|
||||
{
|
||||
int c;
|
||||
assert (!feof (stdin));
|
||||
c = getchar ();
|
||||
switch (c)
|
||||
@@ -175,11 +173,12 @@ main (int argc, char **argv)
|
||||
yylloc.first_column = colNum;]])[
|
||||
if (isalpha (c))
|
||||
{
|
||||
i = 0;
|
||||
char buffer[256];
|
||||
unsigned i = 0;
|
||||
|
||||
do
|
||||
{
|
||||
buffer[i++] = c;
|
||||
buffer[i++] = (char) c;
|
||||
colNum += 1;
|
||||
assert (i != sizeof buffer - 1);
|
||||
c = getchar ();
|
||||
|
||||
@@ -1000,8 +1000,7 @@ static int
|
||||
merge (YYSTYPE s1, YYSTYPE s2)
|
||||
{
|
||||
/* Not invoked. */
|
||||
char dummy = s1.dummy + s2.dummy;
|
||||
return dummy;
|
||||
return s1.dummy + s2.dummy;
|
||||
}
|
||||
|
||||
]AT_YYERROR_DEFINE[
|
||||
@@ -1119,7 +1118,7 @@ change_lookahead:
|
||||
|
||||
]AT_YYERROR_DEFINE[
|
||||
]AT_YYLEX_DEFINE(["ab"],
|
||||
[yylval.value = res + 'A' - 'a'])[
|
||||
[yylval.value = (char) (res + 'A' - 'a')])[
|
||||
|
||||
static void
|
||||
print_lookahead (char const *reduction)
|
||||
@@ -1319,11 +1318,11 @@ static int
|
||||
yylex (void)
|
||||
{
|
||||
static char const input[] = "abcdddd";
|
||||
static size_t toknum;
|
||||
assert (toknum < sizeof input);
|
||||
static int toknum = 0;
|
||||
assert (toknum < (int) sizeof input);
|
||||
yylloc.first_line = yylloc.last_line = 1;
|
||||
yylloc.first_column = yylloc.last_column = toknum + 1;
|
||||
yylval.value = input[toknum] + 'A' - 'a';
|
||||
yylval.value = (char) (input[toknum] + 'A' - 'a');
|
||||
return input[toknum++];
|
||||
}
|
||||
|
||||
@@ -1350,8 +1349,7 @@ print_lookahead (char const *reduction)
|
||||
static char
|
||||
merge (union YYSTYPE s1, union YYSTYPE s2)
|
||||
{
|
||||
char dummy = s1.value + s2.value;
|
||||
return dummy;
|
||||
return (char) (s1.value + s2.value);
|
||||
}
|
||||
|
||||
int
|
||||
@@ -1578,8 +1576,8 @@ static int
|
||||
yylex (YYSTYPE *lvalp, YYLTYPE *llocp)
|
||||
{
|
||||
static char const input[] = "ab";
|
||||
static size_t toknum;
|
||||
assert (toknum < sizeof input);
|
||||
static int toknum = 0;
|
||||
assert (toknum < (int) sizeof input);
|
||||
lvalp->dummy = 0;
|
||||
llocp->first_line = llocp->last_line = 2;
|
||||
llocp->first_column = toknum + 1;
|
||||
|
||||
@@ -429,7 +429,7 @@ static
|
||||
res = input[toknum++];
|
||||
]$2[;]AT_LOCATION_IF([[
|
||||
]AT_LOC_FIRST_LINE[ = ]AT_LOC_LAST_LINE[ = 1;
|
||||
]AT_LOC_FIRST_COLUMN[ = ]AT_LOC_LAST_COLUMN[ = toknum;]])[
|
||||
]AT_LOC_FIRST_COLUMN[ = ]AT_LOC_LAST_COLUMN[ = ]AT_CXX_IF([(unsigned )], [(int)])[toknum;]])[
|
||||
return res;
|
||||
}]dnl
|
||||
])
|
||||
|
||||
@@ -401,7 +401,7 @@ yylex (void)
|
||||
static int
|
||||
get_args (int argc, const char **argv)
|
||||
{
|
||||
int res;
|
||||
long res;
|
||||
char *endp;
|
||||
assert (argc == 2); (void) argc;
|
||||
res = strtol (argv[1], &endp, 10);
|
||||
@@ -409,7 +409,7 @@ get_args (int argc, const char **argv)
|
||||
assert (0 <= res);
|
||||
assert (res <= INT_MAX);
|
||||
assert (errno != ERANGE);
|
||||
return res;
|
||||
return (int) res;
|
||||
}
|
||||
|
||||
int
|
||||
|
||||
@@ -163,7 +163,7 @@ m4_foreach([b4_skel], [[yacc.c], [glr.c], [lalr1.cc], [glr.cc]],
|
||||
[if (res)
|
||||
{
|
||||
AT_VAL.ival = (res - '0') * 10;
|
||||
AT_VAL.fval = (res - '0') / 10.f;
|
||||
AT_VAL.fval = (float) (res - '0') / 10.f;
|
||||
}],
|
||||
[30 0.3])
|
||||
|
||||
|
||||
Reference in New Issue
Block a user