File tree Expand file tree Collapse file tree 6 files changed +23
-19
lines changed
regression/verilog/expressions Expand file tree Collapse file tree 6 files changed +23
-19
lines changed Original file line number Diff line number Diff line change 11# EBMC 5.8
22
3+ * SystemVerilog: semantics fix for size casts
4+
35# EBMC 5.7
46
57* Verilog: --initial-zero changes the default value from nondet to zero
Original file line number Diff line number Diff line change 1- KNOWNBUG
1+ CORE
22size_cast3.sv
33--module main
44^EXIT=0$
55^SIGNAL=0$
66--
77^warning: ignoring
88--
9- This is not yet implemented.
Original file line number Diff line number Diff line change 1- KNOWNBUG
1+ CORE
22static_cast3.sv
33--module main
44^EXIT=0$
55^SIGNAL=0$
66--
77^warning: ignoring
88--
9- This is not yet implemented.
Original file line number Diff line number Diff line change @@ -2554,12 +2554,6 @@ class verilog_explicit_size_cast_exprt : public binary_exprt
25542554 {
25552555 return op1 ();
25562556 }
2557-
2558- // lower to typecast
2559- exprt lower () const
2560- {
2561- return typecast_exprt{op (), type ()};
2562- }
25632557};
25642558
25652559inline const verilog_explicit_size_cast_exprt &
@@ -2655,11 +2649,6 @@ class verilog_explicit_type_cast_exprt : public unary_exprt
26552649 std::move(__type))
26562650 {
26572651 }
2658-
2659- exprt lower () const
2660- {
2661- return typecast_exprt{op (), type ()};
2662- }
26632652};
26642653
26652654inline const verilog_explicit_type_cast_exprt &
Original file line number Diff line number Diff line change @@ -471,16 +471,25 @@ exprt verilog_lowering(exprt expr)
471471 }
472472 else if (expr.id () == ID_verilog_explicit_type_cast)
473473 {
474- return verilog_lowering_cast (
475- to_typecast_expr (to_verilog_explicit_type_cast_expr (expr).lower ()));
474+ // These act like an assignment, and hence, the type checker
475+ // has already converted the argument to the target type.
476+ auto &type_cast = to_verilog_explicit_type_cast_expr (expr);
477+ DATA_INVARIANT (
478+ type_cast.op ().type () == type_cast.type (), " type cast type consistency" );
479+ return type_cast.op ();
476480 }
477481 else if (expr.id () == ID_verilog_explicit_signing_cast)
478482 {
479483 return to_verilog_explicit_signing_cast_expr (expr).lower ();
480484 }
481485 else if (expr.id () == ID_verilog_explicit_size_cast)
482486 {
483- return to_verilog_explicit_size_cast_expr (expr).lower ();
487+ // These act like an assignment, and hence, the type checker
488+ // has already converted the argument to the target type.
489+ auto &size_cast = to_verilog_explicit_size_cast_expr (expr);
490+ DATA_INVARIANT (
491+ size_cast.op ().type () == size_cast.type (), " size cast type consistency" );
492+ return size_cast.op ();
484493 }
485494 else if (
486495 expr.id () == ID_verilog_streaming_concatenation_left_to_right ||
Original file line number Diff line number Diff line change @@ -2694,9 +2694,10 @@ exprt verilog_typecheck_exprt::convert_unary_expr(unary_exprt expr)
26942694 else if (expr.id () == ID_verilog_explicit_type_cast)
26952695 {
26962696 // SystemVerilog has got type'(expr). This is an explicit
2697- // type cast.
2697+ // type cast. These are assignment contexts.
26982698 convert_expr (expr.op ());
26992699 expr.type () = elaborate_type (expr.type ());
2700+ assignment_conversion (expr.op (), expr.type ());
27002701 }
27012702 else if (expr.id () == ID_verilog_explicit_signing_cast)
27022703 {
@@ -3319,6 +3320,11 @@ exprt verilog_typecheck_exprt::convert_binary_expr(binary_exprt expr)
33193320 << " cannot perform size cast on " << to_string (op_type);
33203321 }
33213322
3323+ // These act like an assignment (1800-2017 6.24.1)
3324+ assignment_conversion (expr.rhs (), expr.type ());
3325+
3326+ CHECK_RETURN (expr.rhs ().type () == expr.type ());
3327+
33223328 return std::move (expr);
33233329 }
33243330 else if (
You can’t perform that action at this time.
0 commit comments