Fix handling of ref types in initial values of type parameters (#4304)

This commit is contained in:
Ryszard Rozak
2023-06-20 14:10:07 -04:00
committed by GitHub
parent 63b2dbb827
commit 9ee5fd0585
3 changed files with 27 additions and 1 deletions
+1
View File
@@ -1077,6 +1077,7 @@ public:
AstRefDType(FileLine* fl, FlagTypeOfExpr, AstNode* typeofp)
: ASTGEN_SUPER_RefDType(fl) {
this->typeofp(typeofp);
if (AstNodeDType* const dtp = VN_CAST(typeofp, NodeDType)) refDTypep(dtp);
}
ASTGEN_MEMBERS_AstRefDType;
// METHODS
+1 -1
View File
@@ -709,7 +709,7 @@ class ParamProcessor final : public VNDeleter {
}
} else if (AstParamTypeDType* const modvarp = pinp->modPTypep()) {
AstNodeDType* const exprp = VN_CAST(pinp->exprp(), NodeDType);
const AstNodeDType* const origp = modvarp->subDTypep();
const AstNodeDType* const origp = modvarp->skipRefToEnump();
if (!exprp) {
pinp->v3error("Parameter type pin value isn't a type: Param "
<< pinp->prettyNameQ() << " of " << nodep->prettyNameQ());
+25
View File
@@ -33,14 +33,39 @@ class Cls2;
typedef Bar#(Cls2) type_id;
endclass
typedef int my_int;
class ClsTypedefParam #(type T=my_int);
int x;
endclass
class uvm_sequencer #(type REQ=int, RSP=REQ);
int x;
typedef uvm_sequencer #(REQ, RSP) this_type;
endclass
module t;
initial begin
Cls1::type_id bar1 = new;
Cls2::type_id bar2 = new;
ClsTypedefParam #(int) cls_int = new;
ClsTypedefParam#() cls_def;
uvm_sequencer #(int, int) uvm_seq1 = new;
uvm_sequencer #(int, int)::this_type uvm_seq2;
if (bar1.get_x() != 1) $stop;
if (bar2.get_x() != 2) $stop;
cls_int.x = 1;
cls_def = cls_int;
if (cls_def.x != 1) $stop;
uvm_seq1.x = 2;
uvm_seq2 = uvm_seq1;
if (uvm_seq2.x != 2) $stop;
$write("*-* All Finished *-*\n");
$finish;
end