mirror of
https://github.com/verilator/verilator.git
synced 2025-01-22 14:24:18 +00:00
Internal cast preparatory cleanups.
This commit is contained in:
parent
0818d88113
commit
d21b4e3fc7
@ -1175,6 +1175,7 @@ bool AstClass::isClassExtendedFrom(const AstClass* refClassp, const AstClass* ba
|
||||
// TAIL RECURSIVE
|
||||
if (!refClassp || !baseClassp) return false;
|
||||
if (refClassp == baseClassp) return true;
|
||||
if (!refClassp->extendsp()) return false;
|
||||
return isClassExtendedFrom(refClassp->extendsp()->classp(), baseClassp);
|
||||
}
|
||||
void AstClass::dump(std::ostream& str) const {
|
||||
|
@ -5997,12 +5997,17 @@ public:
|
||||
class AstCast final : public AstNode {
|
||||
// Cast to appropriate data type - note lhsp is value, to match AstTypedef, AstCCast, etc
|
||||
public:
|
||||
AstCast(FileLine* fl, AstNode* lhsp, AstNodeDType* dtp)
|
||||
AstCast(FileLine* fl, AstNode* lhsp, VFlagChildDType, AstNodeDType* dtp)
|
||||
: ASTGEN_SUPER(fl) {
|
||||
setOp1p(lhsp);
|
||||
setOp2p(dtp);
|
||||
dtypeFrom(dtp);
|
||||
}
|
||||
AstCast(FileLine* fl, AstNode* lhsp, AstNodeDType* dtp)
|
||||
: ASTGEN_SUPER(fl) {
|
||||
setOp1p(lhsp);
|
||||
dtypeFrom(dtp);
|
||||
}
|
||||
ASTNODE_NODE_FUNCS(Cast)
|
||||
virtual bool hasDType() const override { return true; }
|
||||
virtual string emitVerilog() { return "((%d)'(%l))"; }
|
||||
|
@ -4255,9 +4255,9 @@ expr<nodep>: // IEEE: part of expression/constant_expression/primary
|
||||
//
|
||||
// // IEEE: cast/constant_cast
|
||||
// // expanded from casting_type
|
||||
| simple_type yP_TICK '(' expr ')' { $$ = new AstCast($1->fileline(), $4, $1); }
|
||||
| simple_type yP_TICK '(' expr ')' { $$ = new AstCast($1->fileline(), $4, VFlagChildDType{}, $1); }
|
||||
| yTYPE '(' exprOrDataType ')' yP_TICK '(' expr ')'
|
||||
{ $$ = new AstCast($1, $7, new AstRefDType($1, AstRefDType::FlagTypeOfExpr(), $3)); }
|
||||
{ $$ = new AstCast($1, $7, VFlagChildDType(), new AstRefDType($1, AstRefDType::FlagTypeOfExpr(), $3)); }
|
||||
| ySIGNED yP_TICK '(' expr ')' { $$ = new AstSigned($1, $4); }
|
||||
| yUNSIGNED yP_TICK '(' expr ')' { $$ = new AstUnsigned($1, $4); }
|
||||
| ySTRING yP_TICK '(' expr ')' { $$ = new AstCvtPackString($1, $4); }
|
||||
|
@ -1,9 +0,0 @@
|
||||
%Error-UNSUPPORTED: t/t_castdyn_bad.v:20:11: Unsupported: $cast. Suggest try static cast.
|
||||
: ... In instance t
|
||||
20 | i = $cast(c, b);
|
||||
| ^~~~~
|
||||
%Error-UNSUPPORTED: t/t_castdyn_bad.v:23:7: Unsupported: $cast. Suggest try static cast.
|
||||
: ... In instance t
|
||||
23 | $cast(c, b);
|
||||
| ^~~~~
|
||||
%Error: Exiting due to
|
9
test_regress/t/t_castdyn_run_bad.out
Normal file
9
test_regress/t/t_castdyn_run_bad.out
Normal file
@ -0,0 +1,9 @@
|
||||
%Error-UNSUPPORTED: t/t_castdyn_run_bad.v:20:11: Unsupported: $cast. Suggest try static cast.
|
||||
: ... In instance t
|
||||
20 | i = $cast(c, b);
|
||||
| ^~~~~
|
||||
%Error-UNSUPPORTED: t/t_castdyn_run_bad.v:23:7: Unsupported: $cast. Suggest try static cast.
|
||||
: ... In instance t
|
||||
23 | $cast(c, b);
|
||||
| ^~~~~
|
||||
%Error: Exiting due to
|
Loading…
Reference in New Issue
Block a user