Delay parameter type assignment determination until elaboration

This commit is contained in:
Wilson Snyder
2024-09-21 20:27:41 -04:00
parent e7de2c5a05
commit 5f39c69d19
9 changed files with 59 additions and 5 deletions
+6 -2
View File
@@ -3928,7 +3928,7 @@ class LinkDotResolveVisitor final : public VNVisitor {
nodep->refDTypep(defp);
nodep->classOrPackagep(foundp->classOrPackagep());
}
} else if (AstClass* const defp = foundp ? VN_AS(foundp->nodep(), Class) : nullptr) {
} else if (AstClass* const defp = foundp ? VN_CAST(foundp->nodep(), Class) : nullptr) {
AstPin* const paramsp = nodep->paramsp();
if (paramsp) paramsp->unlinkFrBackWithNext();
AstClassRefDType* const newp
@@ -3941,7 +3941,11 @@ class LinkDotResolveVisitor final : public VNVisitor {
return;
} else {
if (foundp) UINFO(1, "Found sym node: " << foundp->nodep() << endl);
nodep->v3error("Can't find typedef: " << nodep->prettyNameQ());
if (foundp) {
nodep->v3error("Expecting a data type: " << nodep->prettyNameQ());
} else {
nodep->v3error("Can't find typedef: " << nodep->prettyNameQ());
}
}
}
iterateChildren(nodep);
+21 -1
View File
@@ -2137,6 +2137,26 @@ data_type<nodeDTypep>: // ==IEEE: data_type
$$ = GRAMMARP->createArray(refp, $4, true); }
;
data_typeAny<nodeDTypep>: // ==IEEE: data_type (accepting idAny)
// // IEEE: data_type_or_incomplete_class_scoped_type parses same as this
// // as can't tell them apart until link
// // This expansion also replicated elsewhere, IE data_type__AndID
data_typeNoRef { $$ = $1; }
//
// // REFERENCES
//
// // IEEE: [ class_scope | package_scope ] type_identifier { packed_dimension }
// // IEEE: class_type
// // IEEE: ps_covergroup_identifier
// // Don't distinguish between types and classes so all these combined
| packageClassScopeE idAny packed_dimensionListE
{ AstRefDType* const refp = new AstRefDType{$<fl>2, *$2, $1, nullptr};
$$ = GRAMMARP->createArray(refp, $3, true); }
| packageClassScopeE idAny parameter_value_assignmentClass packed_dimensionListE
{ AstRefDType* const refp = new AstRefDType{$<fl>2, *$2, $1, $3};
$$ = GRAMMARP->createArray(refp, $4, true); }
;
data_typeBasic<nodeDTypep>: // IEEE: part of data_type
integer_vector_type signingE rangeListE { $1->setSignedState($2); $$ = GRAMMARP->addRange($1, $3, true); }
| integer_atom_type signingE { $1->setSignedState($2); $$ = $1; }
@@ -3176,7 +3196,7 @@ type_assignment<varp>: // ==IEEE: type_assignment
// // note exptOrDataType being a data_type is only for yPARAMETER yTYPE
idAny/*new-parameter*/ sigAttrListE
{ $$ = VARDONEA($<fl>1, *$1, nullptr, $2); }
| idAny/*new-parameter*/ sigAttrListE '=' data_type
| idAny/*new-parameter*/ sigAttrListE '=' data_typeAny
{ $$ = VARDONEA($<fl>1, *$1, nullptr, $2); $$->valuep($4); }
;