Convert re-defining macro error to warning.
git-svn-id: file://localhost/svn/verilator/trunk/verilator@1001 77ca24e4-aefa-0310-84f0-b9a241c72d87
This commit is contained in:
parent
16d1f2b835
commit
4fb8dcfd4e
2
Changes
2
Changes
|
|
@ -10,6 +10,8 @@ indicates the contributor was also the author of the fix; Thanks!
|
||||||
|
|
||||||
*** Allow multiple .v files on command line. [Stefan Thiede]
|
*** Allow multiple .v files on command line. [Stefan Thiede]
|
||||||
|
|
||||||
|
*** Convert re-defining macro error to warning. [Stefan Thiede]
|
||||||
|
|
||||||
**** Fix genvar to be signed, so "< 0" works properly. [Niranjan Prabhu]
|
**** Fix genvar to be signed, so "< 0" works properly. [Niranjan Prabhu]
|
||||||
|
|
||||||
**** Fix assignments to inputs inside functions/tasks. [Patricio Kaplan]
|
**** Fix assignments to inputs inside functions/tasks. [Patricio Kaplan]
|
||||||
|
|
|
||||||
|
|
@ -1695,6 +1695,23 @@ not really needed. The best solution is to insure that each module is in a
|
||||||
unique file by the same name. Otherwise, make sure all library files are
|
unique file by the same name. Otherwise, make sure all library files are
|
||||||
read in as libraries with -v, instead of automatically with -y.
|
read in as libraries with -v, instead of automatically with -y.
|
||||||
|
|
||||||
|
=item REDEFMACRO
|
||||||
|
|
||||||
|
Warns that you have redefined the same macro with a different value, for
|
||||||
|
example:
|
||||||
|
|
||||||
|
`define MACRO def1
|
||||||
|
//...
|
||||||
|
`define MACRO otherdef
|
||||||
|
|
||||||
|
The best solution is to use a different name for the second macro. If this
|
||||||
|
is not possible, add a undef to indicate the code is overriding the value:
|
||||||
|
|
||||||
|
`define MACRO def1
|
||||||
|
//...
|
||||||
|
`undef MACRO
|
||||||
|
`define MACRO otherdef
|
||||||
|
|
||||||
=item STMTDLY
|
=item STMTDLY
|
||||||
|
|
||||||
Warns that you have a statement with a delayed time in front of it, for
|
Warns that you have a statement with a delayed time in front of it, for
|
||||||
|
|
|
||||||
|
|
@ -53,6 +53,7 @@ public:
|
||||||
IMPLICIT, // Implicit wire
|
IMPLICIT, // Implicit wire
|
||||||
IMPURE, // Impure function not being inlined
|
IMPURE, // Impure function not being inlined
|
||||||
MULTIDRIVEN, // Driven from multiple blocks
|
MULTIDRIVEN, // Driven from multiple blocks
|
||||||
|
REDEFMACRO, // Redefining existing define macro
|
||||||
UNDRIVEN, // No drivers
|
UNDRIVEN, // No drivers
|
||||||
UNOPT, // Unoptimizable block
|
UNOPT, // Unoptimizable block
|
||||||
UNOPTFLAT, // Unoptimizable block after flattening
|
UNOPTFLAT, // Unoptimizable block after flattening
|
||||||
|
|
@ -78,7 +79,7 @@ public:
|
||||||
"BLKANDNBLK",
|
"BLKANDNBLK",
|
||||||
"CASEINCOMPLETE", "CASEOVERLAP", "CASEX", "CMPCONST",
|
"CASEINCOMPLETE", "CASEOVERLAP", "CASEX", "CMPCONST",
|
||||||
"COMBDLY", "STMTDLY", "GENCLK", "IMPLICIT", "IMPURE",
|
"COMBDLY", "STMTDLY", "GENCLK", "IMPLICIT", "IMPURE",
|
||||||
"MULTIDRIVEN",
|
"MULTIDRIVEN", "REDEFMACRO",
|
||||||
"UNDRIVEN", "UNOPT", "UNOPTFLAT", "UNSIGNED", "UNUSED",
|
"UNDRIVEN", "UNOPT", "UNOPTFLAT", "UNSIGNED", "UNUSED",
|
||||||
"VARHIDDEN", "WIDTH",
|
"VARHIDDEN", "WIDTH",
|
||||||
" MAX"
|
" MAX"
|
||||||
|
|
|
||||||
|
|
@ -207,8 +207,8 @@ void V3PreProcImp::define(FileLine* fl, const string& name, const string& value,
|
||||||
UINFO(4,"DEFINE '"<<name<<"' as '"<<value<<"' params '"<<params<<"'"<<endl);
|
UINFO(4,"DEFINE '"<<name<<"' as '"<<value<<"' params '"<<params<<"'"<<endl);
|
||||||
if (defExists(name)) {
|
if (defExists(name)) {
|
||||||
if (!(defValue(name)==value && defParams(name)==params)) { // Duplicate defs are OK
|
if (!(defValue(name)==value && defParams(name)==params)) { // Duplicate defs are OK
|
||||||
fl->v3error("Define already exists: "<<name);
|
fl->v3warn(REDEFMACRO,"Redefining existing define: "<<name<<", with different value: "<<value<<" "<<params);
|
||||||
defFileline(name)->v3error("Previous definition is here.");
|
defFileline(name)->v3warn(REDEFMACRO,"Previous definition is here, with value: "<<defValue(name)<<" "<<defParams(name));
|
||||||
}
|
}
|
||||||
undef(name);
|
undef(name);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,16 @@
|
||||||
|
#!/usr/bin/perl
|
||||||
|
if (!$::Driver) { use FindBin; exec("./driver.pl", @ARGV, $0); die; }
|
||||||
|
# $Id$
|
||||||
|
# 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
|
||||||
|
# General Public License or the Perl Artistic License.
|
||||||
|
|
||||||
|
compile (
|
||||||
|
v_flags2 => ["-Wno-REDEFMACRO"],
|
||||||
|
) if $Last_Self->{v3};
|
||||||
|
|
||||||
|
ok(1);
|
||||||
|
1;
|
||||||
|
|
||||||
|
|
@ -0,0 +1,17 @@
|
||||||
|
// $Id$
|
||||||
|
// DESCRIPTION: Verilator: Verilog Test module
|
||||||
|
//
|
||||||
|
// This file ONLY is placed into the Public Domain, for any use,
|
||||||
|
// without warranty, 2008 by Wilson Snyder.
|
||||||
|
|
||||||
|
module t;
|
||||||
|
|
||||||
|
`define DUP fred
|
||||||
|
`define DUP barney
|
||||||
|
|
||||||
|
`define DUPP paramed(x) (x)
|
||||||
|
`define DUPP paramed(x,z) (x*z)
|
||||||
|
|
||||||
|
initial $stop; // Should have failed
|
||||||
|
|
||||||
|
endmodule
|
||||||
|
|
@ -0,0 +1,26 @@
|
||||||
|
#!/usr/bin/perl
|
||||||
|
if (!$::Driver) { use FindBin; exec("./driver.pl", @ARGV, $0); die; }
|
||||||
|
# $Id$
|
||||||
|
# DESCRIPTION: Verilator: Verilog Test driver/expect definition
|
||||||
|
#
|
||||||
|
# Copyright 2008 by Wilson Snyder. This program is free software; you can
|
||||||
|
# redistribute it and/or modify it under the terms of either the GNU
|
||||||
|
# General Public License or the Perl Artistic License.
|
||||||
|
|
||||||
|
top_filename("t/t_pp_dupdef.v");
|
||||||
|
|
||||||
|
compile (
|
||||||
|
v_flags2 => ["--lint-only"],
|
||||||
|
fails=>1,
|
||||||
|
expect=>
|
||||||
|
'%Warning-REDEFMACRO: t/t_pp_dupdef.v:\d+: Redefining existing define: DUP, with different value: barney
|
||||||
|
%Warning-REDEFMACRO: Use .* to disable this message.
|
||||||
|
%Warning-REDEFMACRO: t/t_pp_dupdef.v:\d+: Previous definition is here, with value: fred
|
||||||
|
%Warning-REDEFMACRO: t/t_pp_dupdef.v:\d+: Redefining existing define: DUPP, with different value: .*
|
||||||
|
%Warning-REDEFMACRO: t/t_pp_dupdef.v:\d+: Previous definition is here, with value: .*
|
||||||
|
%Error: Exiting due to.*',
|
||||||
|
) if $Last_Self->{v3};
|
||||||
|
|
||||||
|
ok(1);
|
||||||
|
1;
|
||||||
|
|
||||||
Loading…
Reference in New Issue