@@ -266,8 +266,8 @@ exprt verilog_typecheck_exprt::convert_expr_rec(exprt expr)
266266 throw errort ().with_location (expr.source_location ())
267267 << " concatenation expected to have at least one operand" ;
268268 }
269-
270- unsigned width= 0 ;
269+
270+ mp_integer width = 0 ;
271271 bool has_verilogbv=false ;
272272
273273 Forall_operands (it, expr)
@@ -300,23 +300,24 @@ exprt verilog_typecheck_exprt::convert_expr_rec(exprt expr)
300300 if (op.type ().id () == ID_signedbv || op.type ().id () == ID_verilog_signedbv)
301301 {
302302 auto width = get_width (op);
303+ auto width_int = numeric_cast_v<std::size_t >(width);
303304 if (op.type ().id () == ID_verilog_signedbv)
304- op = typecast_exprt ( op, verilog_unsignedbv_typet (width)) ;
305+ op = typecast_exprt{ op, verilog_unsignedbv_typet{width_int}} ;
305306 else
306- op = typecast_exprt ( op, unsignedbv_typet (width)) ;
307+ op = typecast_exprt{ op, unsignedbv_typet{width_int}} ;
307308 }
308309 }
309310
310311 expr.type ()=typet (has_verilogbv?ID_verilog_unsignedbv:ID_unsignedbv);
311- expr.type ().set (ID_width, width);
312-
312+ expr.type ().set (ID_width, integer2string ( width) );
313+
313314 if (has_verilogbv)
314315 {
315316 Forall_operands (it, expr)
316317 if (it->type ().id ()!=ID_verilog_unsignedbv)
317318 {
318- unsigned width= get_width (*it);
319- *it = typecast_exprt{*it, verilog_unsignedbv_typet{width }};
319+ auto width_int = numeric_cast_v<std:: size_t >( get_width (*it) );
320+ *it = typecast_exprt{*it, verilog_unsignedbv_typet{width_int }};
320321 }
321322 }
322323
@@ -2045,13 +2046,14 @@ exprt verilog_typecheck_exprt::convert_replication_expr(replication_exprt expr)
20452046 {
20462047 expr.op0 ()=from_integer (op0, natural_typet ());
20472048
2048- std::size_t new_width = op0.to_ulong () * width;
2049+ auto new_width = op0 * width;
2050+ auto new_width_int = numeric_cast_v<std::size_t >(new_width);
20492051
20502052 if (op1.type ().id ()==ID_verilog_unsignedbv ||
20512053 op1.type ().id ()==ID_verilog_signedbv)
2052- expr.type ()= verilog_unsignedbv_typet (new_width) ;
2054+ expr.type () = verilog_unsignedbv_typet{new_width_int} ;
20532055 else
2054- expr.type ()= unsignedbv_typet (new_width) ;
2056+ expr.type () = unsignedbv_typet{new_width_int} ;
20552057 }
20562058
20572059 return std::move (expr);
@@ -2327,10 +2329,10 @@ exprt verilog_typecheck_exprt::convert_trinary_expr(ternary_exprt expr)
23272329 if (op2 < offset)
23282330 {
23292331 auto padding_width = offset - op2;
2330- auto padding =
2331- from_integer ( 0 , unsignedbv_typet{(padding_width). to_ulong ( )});
2332- auto new_type =
2333- unsignedbv_typet{ (get_width (op0.type ()) + padding_width). to_ulong ( )};
2332+ auto padding = from_integer (
2333+ 0 , unsignedbv_typet{numeric_cast_v<std:: size_t > (padding_width)});
2334+ auto new_type = unsignedbv_typet{
2335+ numeric_cast_v<std:: size_t > (get_width (op0.type ()) + padding_width)};
23342336 expr.op0 () = concatenation_exprt (expr.op0 (), padding, new_type);
23352337 op2 += padding_width;
23362338 op1 += padding_width;
@@ -2339,16 +2341,17 @@ exprt verilog_typecheck_exprt::convert_trinary_expr(ternary_exprt expr)
23392341 if (op1 >= width + offset)
23402342 {
23412343 auto padding_width = op1 - (width + offset) + 1 ;
2342- auto padding =
2343- from_integer ( 0 , unsignedbv_typet{padding_width. to_ulong ( )});
2344- auto new_type =
2345- unsignedbv_typet{ (get_width (op0.type ()) + padding_width). to_ulong ( )};
2344+ auto padding = from_integer (
2345+ 0 , unsignedbv_typet{numeric_cast_v<std:: size_t >(padding_width )});
2346+ auto new_type = unsignedbv_typet{
2347+ numeric_cast_v<std:: size_t > (get_width (op0.type ()) + padding_width)};
23462348 expr.op0 () = concatenation_exprt (padding, expr.op0 (), new_type);
23472349 }
23482350
23492351 // Part-select expressions are unsigned, even if the
23502352 // entire expression is selected!
2351- auto expr_type = unsignedbv_typet ((op1 - op2).to_ulong () + 1 );
2353+ auto expr_type =
2354+ unsignedbv_typet{numeric_cast_v<std::size_t >(op1 - op2 + 1 )};
23522355
23532356 op2 -= offset;
23542357 op1 -= offset;
0 commit comments