parser: warn about hexadecimal token numbers in Yacc mode

* src/scan-gram.l (scan_integer): Warn.
* tests/input.at (Yacc warnings on symbols): Check.
This commit is contained in:
Akim Demaille
2018-12-13 18:22:43 +01:00
parent aadf6c0bf3
commit 953a95695a
2 changed files with 7 additions and 0 deletions

View File

@@ -846,6 +846,10 @@ static unsigned long
scan_integer (char const *number, int base, location loc) scan_integer (char const *number, int base, location loc)
{ {
verify (INT_MAX < ULONG_MAX); verify (INT_MAX < ULONG_MAX);
if (base == 16)
complain (&loc, Wyacc,
_("POSIX Yacc does not support hexadecimal literals"));
unsigned long num = strtoul (number, NULL, base); unsigned long num = strtoul (number, NULL, base);
if (INT_MAX < num) if (INT_MAX < num)

View File

@@ -147,6 +147,9 @@ AT_BISON_CHECK([-fcaret -Wyacc input.y], [0], [],
[[input.y:1.1-6: warning: POSIX Yacc does not support %nterm [-Wyacc] [[input.y:1.1-6: warning: POSIX Yacc does not support %nterm [-Wyacc]
%nterm exp %nterm exp
^^^^^^ ^^^^^^
input.y:2.12-15: warning: POSIX Yacc does not support hexadecimal literals [-Wyacc]
%token NUM 0x40 "number"
^^^^
]]) ]])
AT_CLEANUP AT_CLEANUP