mirror of
https://github.com/verilator/verilator.git
synced 2025-04-27 19:16:53 +00:00
Add error when number missing value.
This commit is contained in:
parent
b0669f3aca
commit
559852f60b
@ -110,13 +110,12 @@ void V3Number::V3NumberCreate(AstNode* nodep, const char* sourcep, FileLine* fl)
|
||||
bool unbased = false;
|
||||
char base = '\0';
|
||||
if (value_startp != sourcep) { // Has a '
|
||||
char widthn[100]; char* wp=&widthn[0];
|
||||
const char* cp=sourcep;
|
||||
string widthn;
|
||||
const char* cp = sourcep;
|
||||
for (; *cp; cp++) {
|
||||
if (*cp == '\'') { cp++ ; break; }
|
||||
if (*cp != '_') *wp++ = *cp;
|
||||
if (*cp != '_') widthn += *cp;
|
||||
}
|
||||
*wp++ = '\0';
|
||||
while (*cp == '_') cp++;
|
||||
if (*cp && tolower(*cp)=='s') {
|
||||
cp++; isSigned(true);
|
||||
@ -124,13 +123,13 @@ void V3Number::V3NumberCreate(AstNode* nodep, const char* sourcep, FileLine* fl)
|
||||
if (*cp) { base=*cp; cp++; }
|
||||
value_startp = cp;
|
||||
|
||||
if (atoi(widthn)) {
|
||||
if (atoi(widthn) < 0 || atoi(widthn) > MAX_WIDTH) {
|
||||
if (atoi(widthn.c_str())) {
|
||||
if (atoi(widthn.c_str()) < 0 || atoi(widthn.c_str()) > MAX_WIDTH) {
|
||||
// atoi might convert large number to negative, so can't tell which
|
||||
v3error("Unsupported: Width of number exceeds implementation limit: "<<sourcep);
|
||||
width(MAX_WIDTH, true);
|
||||
} else {
|
||||
width(atoi(widthn), true);
|
||||
width(atoi(widthn.c_str()), true);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -138,7 +137,7 @@ void V3Number::V3NumberCreate(AstNode* nodep, const char* sourcep, FileLine* fl)
|
||||
base = 'd';
|
||||
}
|
||||
|
||||
for (int i=0; i<words(); i++) m_value[i]=m_valueX[i] = 0;
|
||||
for (int i = 0; i < words(); ++i) m_value[i] = m_valueX[i] = 0;
|
||||
|
||||
// Special SystemVerilog unsized constructs
|
||||
if (base == '0') {
|
||||
@ -162,6 +161,9 @@ void V3Number::V3NumberCreate(AstNode* nodep, const char* sourcep, FileLine* fl)
|
||||
|
||||
// Ignore leading blanks
|
||||
while (*value_startp=='_' || isspace(*value_startp)) value_startp++;
|
||||
if (!*value_startp && !m_autoExtend) {
|
||||
v3error("Number is missing value digits: "<<sourcep);
|
||||
}
|
||||
|
||||
int obit = 0; // Start at LSB
|
||||
if (tolower(base) == 'd') {
|
||||
|
10
test_regress/t/t_number_bad.out
Normal file
10
test_regress/t/t_number_bad.out
Normal file
@ -0,0 +1,10 @@
|
||||
%Error: t/t_number_bad.v:8: Number is missing value digits: 32'd
|
||||
parameter integer FOO2 = 32'd-6;
|
||||
^~~~
|
||||
%Error: t/t_number_bad.v:9: Number is missing value digits: 32'd
|
||||
parameter integer FOO3 = 32'd;
|
||||
^~~~
|
||||
%Error: t/t_number_bad.v:10: Number is missing value digits: 32'h
|
||||
parameter integer FOO4 = 32'h;
|
||||
^~~~
|
||||
%Error: Exiting due to
|
18
test_regress/t/t_number_bad.pl
Executable file
18
test_regress/t/t_number_bad.pl
Executable file
@ -0,0 +1,18 @@
|
||||
#!/usr/bin/perl
|
||||
if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); die; }
|
||||
# DESCRIPTION: Verilator: Verilog Test driver/expect definition
|
||||
#
|
||||
# Copyright 2003 by Wilson Snyder. This program is free software; you can
|
||||
# redistribute it and/or modify it under the terms of either the GNU
|
||||
# Lesser General Public License Version 3 or the Perl Artistic License
|
||||
# Version 2.0.
|
||||
|
||||
scenarios(linter => 1);
|
||||
|
||||
lint(
|
||||
fails => 1,
|
||||
expect_filename => $Self->{golden_filename},
|
||||
);
|
||||
|
||||
ok(1);
|
||||
1;
|
12
test_regress/t/t_number_bad.v
Normal file
12
test_regress/t/t_number_bad.v
Normal file
@ -0,0 +1,12 @@
|
||||
// DESCRIPTION: Verilator: Test of select from constant
|
||||
//
|
||||
// This file ONLY is placed into the Public Domain, for any use,
|
||||
// without warranty, 2019 by Wilson Snyder.
|
||||
|
||||
module t (/*AUTOARG*/);
|
||||
|
||||
parameter integer FOO2 = 32'd-6; // Minus doesn't go here
|
||||
parameter integer FOO3 = 32'd;
|
||||
parameter integer FOO4 = 32'h;
|
||||
|
||||
endmodule
|
Loading…
Reference in New Issue
Block a user