mirror of
https://github.com/verilator/verilator.git
synced 2025-04-06 04:32:39 +00:00
Fix comparison of class objects (#4346)
This commit is contained in:
parent
9aa90569bf
commit
da043ca16d
@ -1508,8 +1508,14 @@ public:
|
||||
// For 'if (ptr)...'
|
||||
operator bool() const { return m_objp; }
|
||||
// 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; };
|
||||
bool operator!=(const VlClassRef& 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_OtherClass>
|
||||
bool operator!=(const VlClassRef<T_OtherClass>& rhs) const {
|
||||
return m_objp != rhs.m_objp;
|
||||
};
|
||||
};
|
||||
|
||||
template <typename T, typename U>
|
||||
|
@ -14,13 +14,22 @@ class Cls;
|
||||
int i;
|
||||
endclass
|
||||
|
||||
class ExtendCls extends Cls;
|
||||
endclass
|
||||
|
||||
module t;
|
||||
initial begin
|
||||
Cls a = new;
|
||||
Cls b = new;
|
||||
ExtendCls ext = new;
|
||||
`check_ne(a, b)
|
||||
`check_ne(a, ext)
|
||||
`check_ne(ext, a)
|
||||
a = b;
|
||||
`check_eq(a, b)
|
||||
a = ext;
|
||||
`check_eq(a, ext)
|
||||
`check_eq(ext, a)
|
||||
$write("*-* All Finished *-*\n");
|
||||
$finish;
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user