mirror of
https://github.com/verilator/verilator.git
synced 2025-01-05 22:27:35 +00:00
Fix dynamic casts of null values (#4631)
This commit is contained in:
parent
739521333c
commit
e6135981a5
@ -1685,6 +1685,10 @@ public:
|
||||
|
||||
template <typename T, typename U>
|
||||
static inline bool VL_CAST_DYNAMIC(VlClassRef<T> in, VlClassRef<U>& outr) {
|
||||
if (!in) {
|
||||
outr = VlNull{};
|
||||
return true;
|
||||
}
|
||||
VlClassRef<U> casted = in.template dynamicCast<U>();
|
||||
if (VL_LIKELY(casted)) {
|
||||
outr = casted;
|
||||
@ -1694,6 +1698,12 @@ static inline bool VL_CAST_DYNAMIC(VlClassRef<T> in, VlClassRef<U>& outr) {
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
static inline bool VL_CAST_DYNAMIC(VlNull in, VlClassRef<T>& outr) {
|
||||
outr = VlNull{};
|
||||
return true;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
// VlSampleQueue stores samples for input clockvars in clocking blocks. At a clocking event,
|
||||
// samples from this queue should be written to the correct input clockvar.
|
||||
|
@ -9,6 +9,10 @@ endclass
|
||||
class BasedA extends Base;
|
||||
endclass
|
||||
class BasedB extends Base;
|
||||
static function BasedB getBasedB(bit getNull);
|
||||
BasedB b = new;
|
||||
return getNull ? null : b;
|
||||
endfunction
|
||||
endclass
|
||||
|
||||
module t (/*AUTOARG*/);
|
||||
@ -55,6 +59,18 @@ module t (/*AUTOARG*/);
|
||||
if (i != 1) $stop;
|
||||
if (b != bb) $stop;
|
||||
|
||||
bb = null;
|
||||
b = bb;
|
||||
i = $cast(bbo, b);
|
||||
if (i != 1) $stop;
|
||||
if (b != bb) $stop;
|
||||
|
||||
bb = BasedB::getBasedB(1);
|
||||
b = bb;
|
||||
i = $cast(bbo, b);
|
||||
if (i != 1) $stop;
|
||||
if (b != bb) $stop;
|
||||
|
||||
bb = new;
|
||||
b = bb;
|
||||
bao = ba;
|
||||
|
Loading…
Reference in New Issue
Block a user