diff options
author | Akim Demaille <akim.demaille@gmail.com> | 2018-10-22 11:15:02 +0200 |
---|---|---|
committer | Akim Demaille <akim.demaille@gmail.com> | 2018-10-22 17:49:06 +0200 |
commit | b4b8666e4a9acc4470cfe0146af93ece9f711a34 (patch) | |
tree | 097ca48a023d427207fc88f7da3d56a61ba3cf43 | |
parent | 0021bc3e28edcf1666bacc2c4eb9a0b30232856c (diff) | |
download | bison-b4b8666e4a9acc4470cfe0146af93ece9f711a34.tar.gz |
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.
-rw-r--r-- | tests/actions.at | 14 | ||||
-rw-r--r-- | tests/c++.at | 4 | ||||
-rw-r--r-- | tests/cxx-type.at | 9 | ||||
-rw-r--r-- | tests/glr-regression.at | 18 | ||||
-rw-r--r-- | tests/local.at | 2 | ||||
-rw-r--r-- | tests/torture.at | 4 | ||||
-rw-r--r-- | tests/types.at | 2 |
7 files changed, 25 insertions, 28 deletions
diff --git a/tests/actions.at b/tests/actions.at index 2c8800d9..de3757eb 100644 --- a/tests/actions.at +++ b/tests/actions.at @@ -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 diff --git a/tests/c++.at b/tests/c++.at index 68167d09..c25aca32 100644 --- a/tests/c++.at +++ b/tests/c++.at @@ -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: diff --git a/tests/cxx-type.at b/tests/cxx-type.at index cf58cf85..f3af6f44 100644 --- a/tests/cxx-type.at +++ b/tests/cxx-type.at @@ -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 (); diff --git a/tests/glr-regression.at b/tests/glr-regression.at index 6ca6813d..0f1d2086 100644 --- a/tests/glr-regression.at +++ b/tests/glr-regression.at @@ -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; diff --git a/tests/local.at b/tests/local.at index c0f08d78..6fbaaa91 100644 --- a/tests/local.at +++ b/tests/local.at @@ -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 ]) diff --git a/tests/torture.at b/tests/torture.at index bbf40cc2..eb767f76 100644 --- a/tests/torture.at +++ b/tests/torture.at @@ -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 diff --git a/tests/types.at b/tests/types.at index 6f44e93d..69bc9819 100644 --- a/tests/types.at +++ b/tests/types.at @@ -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]) |