Skip to content

Commit 36c13ef

Browse files
committed
Use non-deprecated variant of to_integer
to_integer requires a constant_exprt as first argument.
1 parent f912519 commit 36c13ef

11 files changed

+33
-22
lines changed

src/ansi-c/c_typecheck_expr.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2591,7 +2591,7 @@ exprt c_typecheck_baset::do_special_functions(
25912591
arg1=1;
25922592
else if(expr.arguments()[1].is_false())
25932593
arg1=0;
2594-
else if(to_integer(expr.arguments()[1], arg1))
2594+
else if(to_integer(to_constant_expr(expr.arguments()[1]), arg1))
25952595
{
25962596
error().source_location = f_op.source_location();
25972597
error() << "__builtin_object_size expects constant as second argument, "

src/ansi-c/c_typecheck_initializer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -725,7 +725,7 @@ designatort c_typecheck_baset::make_designator(
725725

726726
mp_integer index, size;
727727

728-
if(to_integer(tmp_index, index))
728+
if(to_integer(to_constant_expr(tmp_index), index))
729729
{
730730
error().source_location = d_op.op0().source_location();
731731
error() << "expected constant array index designator" << eom;

src/ansi-c/c_typecheck_type.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ void c_typecheck_baset::typecheck_custom_type(typet &type)
316316
make_constant_index(size_expr);
317317

318318
mp_integer size_int;
319-
if(to_integer(size_expr, size_int))
319+
if(to_integer(to_constant_expr(size_expr), size_int))
320320
{
321321
error().source_location=source_location;
322322
error() << "failed to convert bit vector width to constant" << eom;
@@ -354,7 +354,7 @@ void c_typecheck_baset::typecheck_custom_type(typet &type)
354354
make_constant_index(f_expr);
355355

356356
mp_integer f_int;
357-
if(to_integer(f_expr, f_int))
357+
if(to_integer(to_constant_expr(f_expr), f_int))
358358
{
359359
error().source_location = fraction_source_location;
360360
error() << "failed to convert number of fraction bits to constant" << eom;
@@ -386,7 +386,7 @@ void c_typecheck_baset::typecheck_custom_type(typet &type)
386386
make_constant_index(f_expr);
387387

388388
mp_integer f_int;
389-
if(to_integer(f_expr, f_int))
389+
if(to_integer(to_constant_expr(f_expr), f_int))
390390
{
391391
error().source_location = fraction_source_location;
392392
error() << "failed to convert number of fraction bits to constant" << eom;
@@ -559,7 +559,7 @@ void c_typecheck_baset::typecheck_array_type(array_typet &type)
559559
if(tmp_size.is_constant())
560560
{
561561
mp_integer s;
562-
if(to_integer(tmp_size, s))
562+
if(to_integer(to_constant_expr(tmp_size), s))
563563
{
564564
error().source_location = size_source_location;
565565
error() << "failed to convert constant: "
@@ -681,7 +681,7 @@ void c_typecheck_baset::typecheck_vector_type(vector_typet &type)
681681
make_constant_index(size);
682682

683683
mp_integer s;
684-
if(to_integer(size, s))
684+
if(to_integer(to_constant_expr(size), s))
685685
{
686686
error().source_location=source_location;
687687
error() << "failed to convert constant: "
@@ -1171,7 +1171,7 @@ void c_typecheck_baset::typecheck_c_enum_type(typet &type)
11711171
value=1;
11721172
else if(tmp_v.is_false())
11731173
value=0;
1174-
else if(!to_integer(tmp_v, value))
1174+
else if(tmp_v.id() == ID_constant && !to_integer(to_constant_expr(tmp_v), value))
11751175
{
11761176
}
11771177
else
@@ -1381,7 +1381,7 @@ void c_typecheck_baset::typecheck_c_bit_field_type(c_bit_field_typet &type)
13811381
typecheck_expr(width_expr);
13821382
make_constant_index(width_expr);
13831383

1384-
if(to_integer(width_expr, i))
1384+
if(to_integer(to_constant_expr(width_expr), i))
13851385
{
13861386
error().source_location=type.source_location();
13871387
error() << "failed to convert bit field width" << eom;

src/cpp/cpp_constructor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ optionalt<codet> cpp_typecheckt::cpp_constructor(
6868
make_constant_index(tmp_size);
6969

7070
mp_integer s;
71-
if(to_integer(tmp_size, s))
71+
if(to_integer(to_constant_expr(tmp_size), s))
7272
{
7373
error().source_location=source_location;
7474
error() << "array size `" << to_string(size_expr)

src/cpp/cpp_destructor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ optionalt<codet> cpp_typecheckt::cpp_destructor(
4242
make_constant_index(tmp_size);
4343

4444
mp_integer s;
45-
if(to_integer(tmp_size, s))
45+
if(to_integer(to_constant_expr(tmp_size), s))
4646
{
4747
error().source_location=source_location;
4848
error() << "array size `" << to_string(size_expr)

src/cpp/cpp_instantiate_template.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ std::string cpp_typecheckt::template_suffix(
6363
i=1;
6464
else if(e.is_false())
6565
i=0;
66-
else if(to_integer(e, i))
66+
else if(to_integer(to_constant_expr(e), i))
6767
{
6868
error().source_location = expr.find_source_location();
6969
error() << "template argument expression expected to be "

src/cpp/cpp_typecheck_compound_type.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,7 @@ void cpp_typecheckt::typecheck_compound_declarator(
532532
if(value.is_not_nil() && value.id() == ID_constant)
533533
{
534534
mp_integer i;
535-
to_integer(value, i);
535+
to_integer(to_constant_expr(value), i);
536536
if(i!=0)
537537
{
538538
error().source_location = declarator.name().source_location();

src/cpp/cpp_typecheck_enum_type.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ void cpp_typecheckt::typecheck_enum_body(symbolt &enum_symbol)
4040
typecheck_expr(value);
4141
implicit_typecast(value, c_enum_type.subtype());
4242
make_constant(value);
43-
if(to_integer(value, i))
43+
if(to_integer(to_constant_expr(value), i))
4444
{
4545
error().source_location=value.find_source_location();
4646
error() << "failed to produce integer for enum constant" << eom;

src/goto-programs/builtin_functions.cpp

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ void goto_convertt::do_prob_uniform(
8282

8383
mp_integer lb, ub;
8484

85-
if(to_integer(arguments[0], lb) ||
86-
to_integer(arguments[1], ub))
85+
if(to_integer(to_constant_expr(arguments[0]), lb) ||
86+
to_integer(to_constant_expr(arguments[1]), ub))
8787
{
8888
error().source_location=function.find_source_location();
8989
error() << "error converting operands" << eom;
@@ -147,10 +147,19 @@ void goto_convertt::do_prob_coin(
147147
throw 0;
148148
}
149149

150+
if(arguments[1].type().id()!=ID_unsignedbv ||
151+
arguments[1].id()!=ID_constant)
152+
{
153+
error().source_location=function.find_source_location();
154+
error() << "`" << identifier << "' expected second operand to be "
155+
<< "a constant literal of type unsigned long" << eom;
156+
throw 0;
157+
}
158+
150159
mp_integer num, den;
151160

152-
if(to_integer(arguments[0], num) ||
153-
to_integer(arguments[1], den))
161+
if(to_integer(to_constant_expr(arguments[0]), num) ||
162+
to_integer(to_constant_expr(arguments[1]), den))
154163
{
155164
error().source_location=function.find_source_location();
156165
error() << "error converting operands" << eom;

src/util/simplify_expr_int.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1770,7 +1770,7 @@ bool simplify_exprt::simplify_inequality_constant(exprt &expr)
17701770
if(it->is_constant())
17711771
{
17721772
mp_integer i;
1773-
if(!to_integer(*it, i))
1773+
if(!to_integer(to_constant_expr(*it), i))
17741774
{
17751775
constant+=i;
17761776
*it=from_integer(0, it->type());

0 commit comments

Comments
 (0)