aboutsummaryrefslogtreecommitdiffstats
path: root/frontends
diff options
context:
space:
mode:
authorwhitequark <whitequark@whitequark.org>2020-05-18 03:18:42 +0000
committerwhitequark <whitequark@whitequark.org>2020-05-29 06:58:44 +0000
commit13b2963dedebf86129574192b0d4719956e93d82 (patch)
tree2f602265b8c7687fb41a39c7a51fce2b44fe6488 /frontends
parent0d99522b3c2ca2502129110e09f9988874e37abc (diff)
downloadyosys-13b2963dedebf86129574192b0d4719956e93d82.tar.gz
yosys-13b2963dedebf86129574192b0d4719956e93d82.tar.bz2
yosys-13b2963dedebf86129574192b0d4719956e93d82.zip
ilang_lexer: fix check for out of range literal.
Commit ca70a104 did not use a correct check.
Diffstat (limited to 'frontends')
-rw-r--r--frontends/ilang/ilang_lexer.l4
1 files changed, 3 insertions, 1 deletions
diff --git a/frontends/ilang/ilang_lexer.l b/frontends/ilang/ilang_lexer.l
index 62f53d18e..3362ed641 100644
--- a/frontends/ilang/ilang_lexer.l
+++ b/frontends/ilang/ilang_lexer.l
@@ -91,8 +91,10 @@ USING_YOSYS_NAMESPACE
[0-9]+'[01xzm-]* { rtlil_frontend_ilang_yylval.string = strdup(yytext); return TOK_VALUE; }
-?[0-9]+ {
char *end = nullptr;
+ errno = 0;
long value = strtol(yytext, &end, 10);
- if (end != yytext + strlen(yytext))
+ log_assert(end == yytext + strlen(yytext));
+ if (errno == ERANGE)
return TOK_INVALID; // literal out of range of long
if (value < INT_MIN || value > INT_MAX)
return TOK_INVALID; // literal out of range of int (relevant mostly for LP64 platforms)