Fix comparison of class objects (#4346)
This commit is contained in:
parent
9aa90569bf
commit
da043ca16d
|
|
@ -1508,8 +1508,14 @@ public:
|
||||||
// For 'if (ptr)...'
|
// For 'if (ptr)...'
|
||||||
operator bool() const { return m_objp; }
|
operator bool() const { return m_objp; }
|
||||||
// In SV A == B iff both are handles to the same object (IEEE 1800-2017 8.4)
|
// In SV A == B iff both are handles to the same object (IEEE 1800-2017 8.4)
|
||||||
bool operator==(const VlClassRef& rhs) const { return m_objp == rhs.m_objp; };
|
template <typename T_OtherClass>
|
||||||
bool operator!=(const VlClassRef& rhs) const { return m_objp != rhs.m_objp; };
|
bool operator==(const VlClassRef<T_OtherClass>& rhs) const {
|
||||||
|
return m_objp == rhs.m_objp;
|
||||||
|
};
|
||||||
|
template <typename T_OtherClass>
|
||||||
|
bool operator!=(const VlClassRef<T_OtherClass>& rhs) const {
|
||||||
|
return m_objp != rhs.m_objp;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename T, typename U>
|
template <typename T, typename U>
|
||||||
|
|
|
||||||
|
|
@ -14,13 +14,22 @@ class Cls;
|
||||||
int i;
|
int i;
|
||||||
endclass
|
endclass
|
||||||
|
|
||||||
|
class ExtendCls extends Cls;
|
||||||
|
endclass
|
||||||
|
|
||||||
module t;
|
module t;
|
||||||
initial begin
|
initial begin
|
||||||
Cls a = new;
|
Cls a = new;
|
||||||
Cls b = new;
|
Cls b = new;
|
||||||
|
ExtendCls ext = new;
|
||||||
`check_ne(a, b)
|
`check_ne(a, b)
|
||||||
|
`check_ne(a, ext)
|
||||||
|
`check_ne(ext, a)
|
||||||
a = b;
|
a = b;
|
||||||
`check_eq(a, b)
|
`check_eq(a, b)
|
||||||
|
a = ext;
|
||||||
|
`check_eq(a, ext)
|
||||||
|
`check_eq(ext, a)
|
||||||
$write("*-* All Finished *-*\n");
|
$write("*-* All Finished *-*\n");
|
||||||
$finish;
|
$finish;
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue