Fix virtual interface null checks (#5391)
This commit is contained in:
parent
a730daabef
commit
13e0fc7c27
|
|
@ -1787,12 +1787,16 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
//===================================================================
|
//===================================================================
|
||||||
// Represents the null pointer. Used for setting VlClassRef to null instead of
|
// Represents the null pointer. Used for:
|
||||||
// via nullptr_t, to prevent the implicit conversion of 0 to nullptr.
|
// * setting VlClassRef to null instead of via nullptr_t, to prevent the implicit conversion of 0
|
||||||
|
// to nullptr,
|
||||||
|
// * comparing interface pointers to null.
|
||||||
|
|
||||||
struct VlNull final {
|
struct VlNull final {
|
||||||
operator bool() const { return false; }
|
operator bool() const { return false; }
|
||||||
|
bool operator==(void* ptr) const { return !ptr; }
|
||||||
};
|
};
|
||||||
|
inline bool operator==(void* ptr, VlNull) { return !ptr; }
|
||||||
|
|
||||||
//===================================================================
|
//===================================================================
|
||||||
// Verilog class reference container
|
// Verilog class reference container
|
||||||
|
|
|
||||||
|
|
@ -876,8 +876,8 @@ public:
|
||||||
AstNodeDType* skipRefToConstp() const override { return (AstNodeDType*)this; }
|
AstNodeDType* skipRefToConstp() const override { return (AstNodeDType*)this; }
|
||||||
AstNodeDType* skipRefToEnump() const override { return (AstNodeDType*)this; }
|
AstNodeDType* skipRefToEnump() const override { return (AstNodeDType*)this; }
|
||||||
bool similarDType(const AstNodeDType* samep) const override { return this == samep; }
|
bool similarDType(const AstNodeDType* samep) const override { return this == samep; }
|
||||||
int widthAlignBytes() const override { return 1; }
|
int widthAlignBytes() const override { return 0; }
|
||||||
int widthTotalBytes() const override { return 1; }
|
int widthTotalBytes() const override { return 0; }
|
||||||
bool isVirtual() const { return m_virtual; }
|
bool isVirtual() const { return m_virtual; }
|
||||||
void isVirtual(bool flag) {
|
void isVirtual(bool flag) {
|
||||||
m_virtual = flag;
|
m_virtual = flag;
|
||||||
|
|
|
||||||
|
|
@ -2744,7 +2744,6 @@ class WidthVisitor final : public VNVisitor {
|
||||||
UINFO(5, " IFACEREF " << nodep << endl);
|
UINFO(5, " IFACEREF " << nodep << endl);
|
||||||
userIterateChildren(nodep, m_vup);
|
userIterateChildren(nodep, m_vup);
|
||||||
nodep->dtypep(nodep);
|
nodep->dtypep(nodep);
|
||||||
nodep->widthForce(1, 1); // Not really relevant
|
|
||||||
UINFO(4, "dtWidthed " << nodep << endl);
|
UINFO(4, "dtWidthed " << nodep << endl);
|
||||||
}
|
}
|
||||||
void visit(AstNodeUOrStructDType* nodep) override {
|
void visit(AstNodeUOrStructDType* nodep) override {
|
||||||
|
|
@ -7024,7 +7023,7 @@ class WidthVisitor final : public VNVisitor {
|
||||||
= new AstNeqD{nodep->fileline(), VN_AS(underp, NodeExpr),
|
= new AstNeqD{nodep->fileline(), VN_AS(underp, NodeExpr),
|
||||||
new AstConst{nodep->fileline(), AstConst::RealDouble{}, 0.0}};
|
new AstConst{nodep->fileline(), AstConst::RealDouble{}, 0.0}};
|
||||||
linker.relink(newp);
|
linker.relink(newp);
|
||||||
} else if (VN_IS(underVDTypep, ClassRefDType)
|
} else if (VN_IS(underVDTypep, ClassRefDType) || VN_IS(underVDTypep, IfaceRefDType)
|
||||||
|| (VN_IS(underVDTypep, BasicDType)
|
|| (VN_IS(underVDTypep, BasicDType)
|
||||||
&& VN_AS(underVDTypep, BasicDType)->keyword() == VBasicDTypeKwd::CHANDLE)) {
|
&& VN_AS(underVDTypep, BasicDType)->keyword() == VBasicDTypeKwd::CHANDLE)) {
|
||||||
// Allow warning-free "if (handle)"
|
// Allow warning-free "if (handle)"
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,9 @@ module t (/*AUTOARG*/);
|
||||||
initial begin
|
initial begin
|
||||||
va = ia;
|
va = ia;
|
||||||
vb = ia;
|
vb = ia;
|
||||||
|
|
||||||
|
if (va == null) $stop;
|
||||||
|
|
||||||
$display("va==vb? %b", va==vb);
|
$display("va==vb? %b", va==vb);
|
||||||
$display("va!=vb? %b", va!=vb);
|
$display("va!=vb? %b", va!=vb);
|
||||||
vb = ib;
|
vb = ib;
|
||||||
|
|
@ -53,6 +56,8 @@ module t (/*AUTOARG*/);
|
||||||
$display("va.addr=%x", va.addr, " va.data=%x", va.data, " ia.addr=%x", ia.addr, " ia.data=%x", ia.data);
|
$display("va.addr=%x", va.addr, " va.data=%x", va.data, " ia.addr=%x", ia.addr, " ia.data=%x", ia.data);
|
||||||
$display("vb.addr=%x", vb.addr, " vb.data=%x", vb.data, " ib.addr=%x", ib.addr, " ib.data=%x", ib.data);
|
$display("vb.addr=%x", vb.addr, " vb.data=%x", vb.data, " ib.addr=%x", ib.addr, " ib.data=%x", ib.data);
|
||||||
|
|
||||||
|
if (ca.fa) $stop;
|
||||||
|
|
||||||
ca.fa = ia;
|
ca.fa = ia;
|
||||||
ca.fb = ib;
|
ca.fb = ib;
|
||||||
cb.fa = ib;
|
cb.fa = ib;
|
||||||
|
|
@ -60,6 +65,10 @@ module t (/*AUTOARG*/);
|
||||||
gen.x[0] = va;
|
gen.x[0] = va;
|
||||||
gen.x[1] = vb;
|
gen.x[1] = vb;
|
||||||
|
|
||||||
|
if (ca == null) $stop;
|
||||||
|
if (ca.fa == null) $stop;
|
||||||
|
if (!ca.fa ) $stop;
|
||||||
|
|
||||||
pa = va;
|
pa = va;
|
||||||
pb = vb;
|
pb = vb;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue