|
20 | 20 | #include <util/mathematical_expr.h>
|
21 | 21 | #include <util/mathematical_types.h>
|
22 | 22 | #include <util/pointer_expr.h>
|
| 23 | +#include <util/pointer_offset_size.h> |
23 | 24 | #include <util/rational.h>
|
24 | 25 | #include <util/rational_tools.h>
|
25 | 26 | #include <util/simplify_expr.h>
|
@@ -1319,12 +1320,24 @@ void goto_convertt::do_function_call_symbol(
|
1319 | 1320 | goto_programt::make_assignment(lhs, rhs, function.source_location()));
|
1320 | 1321 | }
|
1321 | 1322 |
|
1322 |
| - code_assignt assign{ |
1323 |
| - list_arg, plus_exprt{list_arg, from_integer(1, pointer_diff_type())}}; |
1324 |
| - assign.rhs().set( |
1325 |
| - ID_C_va_arg_type, to_code_type(function.type()).return_type()); |
| 1323 | + exprt rhs; |
| 1324 | + if(list_arg.type() == pointer_type(pointer_type(empty_typet{}))) |
| 1325 | + rhs = plus_exprt{list_arg, from_integer(1, pointer_diff_type())}; |
| 1326 | + else |
| 1327 | + { |
| 1328 | + // handle unexpected va_list types by just enforcing pointer increments by |
| 1329 | + // size-of-void* |
| 1330 | + rhs = typecast_exprt{ |
| 1331 | + plus_exprt{ |
| 1332 | + typecast_exprt{list_arg, pointer_type(char_type())}, |
| 1333 | + from_integer( |
| 1334 | + *pointer_offset_size(pointer_type(empty_typet{}), ns), |
| 1335 | + pointer_diff_type())}, |
| 1336 | + list_arg.type()}; |
| 1337 | + } |
| 1338 | + rhs.set(ID_C_va_arg_type, to_code_type(function.type()).return_type()); |
1326 | 1339 | dest.add(goto_programt::make_assignment(
|
1327 |
| - std::move(assign), function.source_location())); |
| 1340 | + list_arg, std::move(rhs), function.source_location())); |
1328 | 1341 | }
|
1329 | 1342 | else if(identifier=="__builtin_va_copy")
|
1330 | 1343 | {
|
|
0 commit comments