forked from github/verilator
Add circular typedef error, bug1388.
This commit is contained in:
parent
62a7d713a7
commit
ef884143d1
2
Changes
2
Changes
@ -9,6 +9,8 @@ The contributors that suggested a given feature are shown in []. Thanks!
|
||||
|
||||
**** For --xml, add additional information, bug1372. [Jonathan Kimmitt]
|
||||
|
||||
**** Add circular typedef error, bug1388. [Al Grant]
|
||||
|
||||
**** Fix FST tracing of wide arrays, bug1376. [Aleksander Osman]
|
||||
|
||||
**** Fix error when pattern assignment has too few elements, bug1378. [Viktor Tomov]
|
||||
|
@ -929,8 +929,15 @@ void AstRange::dump(std::ostream& str) {
|
||||
if (littleEndian()) str<<" [LITTLE]";
|
||||
}
|
||||
void AstRefDType::dump(std::ostream& str) {
|
||||
static bool s_recursing = false;
|
||||
this->AstNodeDType::dump(str);
|
||||
if (defp()) { str<<" -> "; defp()->dump(str); }
|
||||
if (defp()) {
|
||||
if (!s_recursing) { // Prevent infinite dump if circular typedefs
|
||||
s_recursing = true;
|
||||
str<<" -> "; defp()->dump(str);
|
||||
s_recursing = false;
|
||||
}
|
||||
}
|
||||
else { str<<" -> UNLINKED"; }
|
||||
}
|
||||
void AstNodeClassDType::dump(std::ostream& str) {
|
||||
|
@ -1043,12 +1043,24 @@ private:
|
||||
UINFO(4,"dtWidthed "<<nodep<<endl);
|
||||
}
|
||||
virtual void visit(AstRefDType* nodep) {
|
||||
if (nodep->didWidthAndSet()) return; // This node is a dtype & not both PRELIMed+FINALed
|
||||
userIterateChildren(nodep, NULL);
|
||||
if (nodep->subDTypep()) nodep->refDTypep(iterateEditDTypep(nodep, nodep->subDTypep()));
|
||||
nodep->dtypeFrom(nodep->dtypeSkipRefp());
|
||||
nodep->widthFromSub(nodep->subDTypep());
|
||||
UINFO(4,"dtWidthed "<<nodep<<endl);
|
||||
if (nodep->doingWidth()) { // Early exit if have circular parameter definition
|
||||
nodep->v3error("Typedef's type is circular: "<<nodep->prettyName());
|
||||
nodep->dtypeSetLogicBool();
|
||||
nodep->doingWidth(false);
|
||||
return;
|
||||
}
|
||||
if (nodep->didWidthAndSet()) return; // This node is a dtype & not both PRELIMed+FINALed
|
||||
nodep->doingWidth(true);
|
||||
userIterateChildren(nodep, NULL);
|
||||
if (nodep->subDTypep()) nodep->refDTypep(iterateEditDTypep(nodep, nodep->subDTypep()));
|
||||
// Effectively nodep->dtypeFrom(nodep->dtypeSkipRefp());
|
||||
// But might be recursive, so instead manually recurse into the referenced type
|
||||
if (!nodep->defp()) nodep->v3fatalSrc("Unlinked");
|
||||
nodep->dtypeFrom(nodep->defp());
|
||||
userIterate(nodep->defp(), NULL);
|
||||
nodep->widthFromSub(nodep->subDTypep());
|
||||
UINFO(4,"dtWidthed "<<nodep<<endl);
|
||||
nodep->doingWidth(false);
|
||||
}
|
||||
virtual void visit(AstTypedef* nodep) {
|
||||
if (nodep->didWidthAndSet()) return; // This node is a dtype & not both PRELIMed+FINALed
|
||||
|
2
test_regress/t/t_typedef_circ_bad.out
Normal file
2
test_regress/t/t_typedef_circ_bad.out
Normal file
@ -0,0 +1,2 @@
|
||||
%Error: t/t_typedef_circ_bad.v:5: Typedef's type is circular: a_t
|
||||
%Error: Exiting due to
|
19
test_regress/t/t_typedef_circ_bad.pl
Executable file
19
test_regress/t/t_typedef_circ_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_all => 1);
|
||||
|
||||
compile(
|
||||
v_flags2 => ["--lint-only"],
|
||||
fails => $Self->{vlt_all},
|
||||
expect_filename => $Self->{golden_filename},
|
||||
);
|
||||
|
||||
ok(1);
|
||||
1;
|
6
test_regress/t/t_typedef_circ_bad.v
Normal file
6
test_regress/t/t_typedef_circ_bad.v
Normal file
@ -0,0 +1,6 @@
|
||||
// This file ONLY is placed into the Public Domain, for any use,
|
||||
// without warranty, 2019 by Wilson Snyder
|
||||
|
||||
typedef a_t;
|
||||
typedef a_t b_t;
|
||||
typedef b_t a_t;
|
Loading…
Reference in New Issue
Block a user