@@ -266,8 +266,8 @@ exprt verilog_typecheck_exprt::convert_expr_rec(exprt expr)
266
266
throw errort ().with_location (expr.source_location ())
267
267
<< " concatenation expected to have at least one operand" ;
268
268
}
269
-
270
- unsigned width= 0 ;
269
+
270
+ mp_integer width = 0 ;
271
271
bool has_verilogbv=false ;
272
272
273
273
Forall_operands (it, expr)
@@ -300,23 +300,24 @@ exprt verilog_typecheck_exprt::convert_expr_rec(exprt expr)
300
300
if (op.type ().id () == ID_signedbv || op.type ().id () == ID_verilog_signedbv)
301
301
{
302
302
auto width = get_width (op);
303
+ auto width_int = numeric_cast_v<std::size_t >(width);
303
304
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}} ;
305
306
else
306
- op = typecast_exprt ( op, unsignedbv_typet (width)) ;
307
+ op = typecast_exprt{ op, unsignedbv_typet{width_int}} ;
307
308
}
308
309
}
309
310
310
311
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
+
313
314
if (has_verilogbv)
314
315
{
315
316
Forall_operands (it, expr)
316
317
if (it->type ().id ()!=ID_verilog_unsignedbv)
317
318
{
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 }};
320
321
}
321
322
}
322
323
@@ -2045,13 +2046,14 @@ exprt verilog_typecheck_exprt::convert_replication_expr(replication_exprt expr)
2045
2046
{
2046
2047
expr.op0 ()=from_integer (op0, natural_typet ());
2047
2048
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);
2049
2051
2050
2052
if (op1.type ().id ()==ID_verilog_unsignedbv ||
2051
2053
op1.type ().id ()==ID_verilog_signedbv)
2052
- expr.type ()= verilog_unsignedbv_typet (new_width) ;
2054
+ expr.type () = verilog_unsignedbv_typet{new_width_int} ;
2053
2055
else
2054
- expr.type ()= unsignedbv_typet (new_width) ;
2056
+ expr.type () = unsignedbv_typet{new_width_int} ;
2055
2057
}
2056
2058
2057
2059
return std::move (expr);
@@ -2327,10 +2329,10 @@ exprt verilog_typecheck_exprt::convert_trinary_expr(ternary_exprt expr)
2327
2329
if (op2 < offset)
2328
2330
{
2329
2331
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)};
2334
2336
expr.op0 () = concatenation_exprt (expr.op0 (), padding, new_type);
2335
2337
op2 += padding_width;
2336
2338
op1 += padding_width;
@@ -2339,16 +2341,17 @@ exprt verilog_typecheck_exprt::convert_trinary_expr(ternary_exprt expr)
2339
2341
if (op1 >= width + offset)
2340
2342
{
2341
2343
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)};
2346
2348
expr.op0 () = concatenation_exprt (padding, expr.op0 (), new_type);
2347
2349
}
2348
2350
2349
2351
// Part-select expressions are unsigned, even if the
2350
2352
// 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 )};
2352
2355
2353
2356
op2 -= offset;
2354
2357
op1 -= offset;
0 commit comments