Support type(t) static casting

This commit is contained in:
Wilson Snyder 2020-11-28 17:29:21 -05:00
parent 9a9931fb9d
commit ff262fc4fb
2 changed files with 4 additions and 0 deletions

View File

@ -4219,6 +4219,8 @@ expr<nodep>: // IEEE: part of expression/constant_expression/primary
// // IEEE: cast/constant_cast // // IEEE: cast/constant_cast
// // expanded from casting_type // // 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, $1); }
| yTYPE '(' exprOrDataType ')' yP_TICK '(' expr ')'
{ $$ = new AstCast($1, $7, new AstRefDType($1, AstRefDType::FlagTypeOfExpr(), $3)); }
| ySIGNED yP_TICK '(' expr ')' { $$ = new AstSigned($1, $4); } | ySIGNED yP_TICK '(' expr ')' { $$ = new AstSigned($1, $4); }
| yUNSIGNED yP_TICK '(' expr ')' { $$ = new AstUnsigned($1, $4); } | yUNSIGNED yP_TICK '(' expr ')' { $$ = new AstUnsigned($1, $4); }
| ySTRING yP_TICK '(' expr ')' { $$ = new AstCvtPackString($1, $4); } | ySTRING yP_TICK '(' expr ')' { $$ = new AstCvtPackString($1, $4); }

View File

@ -15,6 +15,8 @@ module t(/*AUTOARG*/);
y = 2.3; y = 2.3;
z = x + y; z = x + y;
if (z != (1.2+2.3)) $stop; if (z != (1.2+2.3)) $stop;
z = type(z)'(22);
if (z != 22.0) $stop;
$write("*-* All Finished *-*\n"); $write("*-* All Finished *-*\n");
$finish; $finish;
end end