Fix this in a constructor (#4533)
This commit is contained in:
parent
1b8228b642
commit
a3c154dcd3
|
|
@ -1477,7 +1477,7 @@ class VlClass VL_NOT_FINAL : public VlDeletable {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// CONSTRUCTORS
|
// CONSTRUCTORS
|
||||||
VlClass() = default;
|
VlClass() { refCountInc(); }
|
||||||
VlClass(const VlClass& copied) {}
|
VlClass(const VlClass& copied) {}
|
||||||
~VlClass() override = default;
|
~VlClass() override = default;
|
||||||
};
|
};
|
||||||
|
|
@ -1526,8 +1526,9 @@ public:
|
||||||
// () required here to avoid narrowing conversion warnings,
|
// () required here to avoid narrowing conversion warnings,
|
||||||
// when a new() has an e.g. CData type and passed a 1U.
|
// when a new() has an e.g. CData type and passed a 1U.
|
||||||
: m_objp{new T_Class(std::forward<T_Args>(args)...)} {
|
: m_objp{new T_Class(std::forward<T_Args>(args)...)} {
|
||||||
|
// refCountInc was moved to the constructor of T_Class
|
||||||
|
// to fix self references in constructor.
|
||||||
m_objp->m_deleterp = &deleter;
|
m_objp->m_deleterp = &deleter;
|
||||||
refCountInc();
|
|
||||||
}
|
}
|
||||||
// Explicit to avoid implicit conversion from 0
|
// Explicit to avoid implicit conversion from 0
|
||||||
explicit VlClassRef(T_Class* objp)
|
explicit VlClassRef(T_Class* objp)
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,21 @@
|
||||||
|
#!/usr/bin/env perl
|
||||||
|
if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); die; }
|
||||||
|
# DESCRIPTION: Verilator: Verilog Test driver/expect definition
|
||||||
|
#
|
||||||
|
# Copyright 2020 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.
|
||||||
|
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
|
||||||
|
|
||||||
|
scenarios(simulator => 1);
|
||||||
|
|
||||||
|
compile(
|
||||||
|
);
|
||||||
|
|
||||||
|
execute(
|
||||||
|
check_finished => 1,
|
||||||
|
);
|
||||||
|
|
||||||
|
ok(1);
|
||||||
|
1;
|
||||||
|
|
@ -0,0 +1,26 @@
|
||||||
|
// DESCRIPTION: Verilator: Verilog Test module
|
||||||
|
//
|
||||||
|
// This file ONLY is placed under the Creative Commons Public Domain, for
|
||||||
|
// any use, without warranty, 2023 by Antmicro Ltd.
|
||||||
|
// SPDX-License-Identifier: CC0-1.0
|
||||||
|
|
||||||
|
class Cls;
|
||||||
|
bit x = 1'b0;
|
||||||
|
function new;
|
||||||
|
Cls c;
|
||||||
|
if (c == this) begin
|
||||||
|
x = 1'b1;
|
||||||
|
end
|
||||||
|
endfunction
|
||||||
|
endclass
|
||||||
|
|
||||||
|
module t (/*AUTOARG*/);
|
||||||
|
Cls c;
|
||||||
|
initial begin
|
||||||
|
c = new;
|
||||||
|
if (c.x) $stop;
|
||||||
|
|
||||||
|
$write("*-* All Finished *-*\n");
|
||||||
|
$finish;
|
||||||
|
end
|
||||||
|
endmodule
|
||||||
Loading…
Reference in New Issue