forked from github/verilator
Add error on misused define.
This commit is contained in:
parent
fe9cf9bd42
commit
fe94f9891b
2
Changes
2
Changes
@ -5,6 +5,8 @@ The contributors that suggested a given feature are shown in []. Thanks!
|
||||
|
||||
* Verilator 4.027 devel
|
||||
|
||||
**** Add error on misused define. [Topa Tota]
|
||||
|
||||
|
||||
* Verilator 4.026 2020-01-11
|
||||
|
||||
|
@ -244,6 +244,11 @@ bom [\357\273\277]
|
||||
// Note paren level 0 means before "(" of starting args
|
||||
// Level 1 means "," between arguments
|
||||
// Level 2+ means one inside the () of an argument
|
||||
if (LEXP->m_parenLevel == 1) { // Starting (
|
||||
if (!VString::isWhitespace(LEXP->m_defValue)) {
|
||||
yyerrorf("Illegal text before '(' that starts define arguments");
|
||||
}
|
||||
}
|
||||
if (LEXP->m_parenLevel>1) {
|
||||
appendDefValue(yytext, yyleng); FL_BRK;
|
||||
} else {
|
||||
|
@ -114,6 +114,13 @@ string VString::spaceUnprintable(const string& str) {
|
||||
return out;
|
||||
}
|
||||
|
||||
bool VString::isWhitespace(const string& str) {
|
||||
for (string::const_iterator pos = str.begin(); pos != str.end(); ++pos) {
|
||||
if (!isspace(*pos)) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//######################################################################
|
||||
// VHashSha256
|
||||
|
||||
|
@ -74,6 +74,8 @@ public:
|
||||
// Replace any unprintable with space
|
||||
// This includes removing tabs, so column tracking is correct
|
||||
static string spaceUnprintable(const string& str);
|
||||
// Return true if only whitespace or ""
|
||||
static bool isWhitespace(const string& str);
|
||||
};
|
||||
|
||||
//######################################################################
|
||||
|
7
test_regress/t/t_pp_defparen_bad.out
Normal file
7
test_regress/t/t_pp_defparen_bad.out
Normal file
@ -0,0 +1,7 @@
|
||||
%Error: t/t_pp_defparen_bad.v:9: Illegal text before '(' that starts define arguments
|
||||
( 1,2)
|
||||
^
|
||||
%Error: t/t_pp_defparen_bad.v:9: syntax error, unexpected '('
|
||||
((val 1) + (2))
|
||||
^
|
||||
%Error: Exiting due to
|
19
test_regress/t/t_pp_defparen_bad.pl
Executable file
19
test_regress/t/t_pp_defparen_bad.pl
Executable file
@ -0,0 +1,19 @@
|
||||
#!/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(vlt => 1);
|
||||
|
||||
lint(
|
||||
verilator_flags2 => ["-Wpedantic"],
|
||||
fails => 1,
|
||||
expect_filename => $Self->{golden_filename},
|
||||
);
|
||||
|
||||
ok(1);
|
||||
1;
|
9
test_regress/t/t_pp_defparen_bad.v
Normal file
9
test_regress/t/t_pp_defparen_bad.v
Normal file
@ -0,0 +1,9 @@
|
||||
// DESCRIPTION: Verilator: Verilog Test module
|
||||
//
|
||||
// This file ONLY is placed into the Public Domain, for any use,
|
||||
// without warranty, 2020 by Wilson Snyder.
|
||||
|
||||
`define test(a1,a2) ((a1) + (a2))
|
||||
|
||||
`test val
|
||||
( 1,2)
|
Loading…
Reference in New Issue
Block a user