mirror of
				https://github.com/YosysHQ/yosys
				synced 2025-11-04 05:19:11 +00:00 
			
		
		
		
	Merge pull request #2097 from whitequark/ilang_lexer-fix-erange
ilang_lexer: fix check for out of range literal
This commit is contained in:
		
						commit
						626c74adbd
					
				
					 1 changed files with 3 additions and 1 deletions
				
			
		| 
						 | 
					@ -91,8 +91,10 @@ USING_YOSYS_NAMESPACE
 | 
				
			||||||
[0-9]+'[01xzm-]*	{ rtlil_frontend_ilang_yylval.string = strdup(yytext); return TOK_VALUE; }
 | 
					[0-9]+'[01xzm-]*	{ rtlil_frontend_ilang_yylval.string = strdup(yytext); return TOK_VALUE; }
 | 
				
			||||||
-?[0-9]+		{
 | 
					-?[0-9]+		{
 | 
				
			||||||
	char *end = nullptr;
 | 
						char *end = nullptr;
 | 
				
			||||||
 | 
						errno = 0;
 | 
				
			||||||
	long value = strtol(yytext, &end, 10);
 | 
						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
 | 
							return TOK_INVALID; // literal out of range of long
 | 
				
			||||||
	if (value < INT_MIN || value > INT_MAX)
 | 
						if (value < INT_MIN || value > INT_MAX)
 | 
				
			||||||
		return TOK_INVALID; // literal out of range of int (relevant mostly for LP64 platforms)
 | 
							return TOK_INVALID; // literal out of range of int (relevant mostly for LP64 platforms)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue