Skip to content

Commit

Permalink
Verilog: separate ID for explicit typecast expressions
Browse files Browse the repository at this point in the history
This is to avoid any confusion with automatically generated, implicit typecasts.
  • Loading branch information
kroening committed Apr 21, 2024
1 parent d3071f4 commit d9f3402
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/hw_cbmc_irep_ids.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ IREP_ID_TWO(C_little_endian, #little_endian)
IREP_ID_ONE(ports)
IREP_ID_ONE(inst)
IREP_ID_ONE(Verilog)
IREP_ID_ONE(verilog_explicit_cast)
IREP_ID_ONE(verilog_non_indexed_part_select)
IREP_ID_ONE(verilog_indexed_part_select_plus)
IREP_ID_ONE(verilog_indexed_part_select_minus)
Expand Down
4 changes: 3 additions & 1 deletion src/verilog/parser.y
Original file line number Diff line number Diff line change
Expand Up @@ -3140,7 +3140,9 @@ time_literal: TOK_TIME_LITERAL

cast:
casting_type '\'' '(' expression ')'
{ init($$, ID_typecast); stack_expr($$).type() = stack_type($1); mto($$, $4); }
{ init($$, ID_verilog_explicit_cast);
stack_expr($$).type() = stack_type($1);
mto($$, $4); }
;
// System Verilog standard 1800-2017
Expand Down
3 changes: 2 additions & 1 deletion src/verilog/verilog_typecheck_expr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1877,12 +1877,13 @@ exprt verilog_typecheck_exprt::convert_unary_expr(unary_exprt expr)
make_boolean(expr.op());
expr.type()=bool_typet();
}
else if(expr.id() == ID_typecast)
else if(expr.id() == ID_verilog_explicit_cast)
{
// System Verilog has got type'(expr). This is an explicit
// type cast.
expr.type() = convert_type(expr.type());
convert_expr(expr.op());
expr.id(ID_typecast);
}
else
{
Expand Down

0 comments on commit d9f3402

Please sign in to comment.