File tree 4 files changed +50
-3
lines changed
4 files changed +50
-3
lines changed Original file line number Diff line number Diff line change
1
+ void a ()
2
+ {
3
+ // Uses the implicit signature of undefined functions: int c(void)
4
+ int b ;
5
+ b = c ();
6
+ __CPROVER_assert (b == 0 , "expected to fail" );
7
+ }
8
+ void c (void )
9
+ {
10
+ // Actually... don't return anything
11
+ // So the results will be non-deterministic
12
+ }
13
+
14
+ int main (int argc , char * * argv )
15
+ {
16
+ a ();
17
+ return 0 ;
18
+ }
Original file line number Diff line number Diff line change
1
+ CORE
2
+ main.c
3
+
4
+ ^VERIFICATION FAILED$
5
+ ^EXIT=10$
6
+ ^SIGNAL=0$
7
+ --
8
+ Reason: Check return value
9
+ ^warning: ignoring
Original file line number Diff line number Diff line change @@ -762,6 +762,16 @@ void goto_convertt::do_function_call_symbol(
762
762
code_function_callt function_call (lhs, function, arguments);
763
763
function_call.add_source_location () = function.source_location ();
764
764
765
+ // remove void-typed assignments, which may have been created when the
766
+ // front-end was unable to detect them in type checking for a lack of
767
+ // available declarations
768
+ if (
769
+ lhs.is_not_nil () &&
770
+ to_code_type (symbol->type ).return_type ().id () == ID_empty)
771
+ {
772
+ function_call.lhs ().make_nil ();
773
+ }
774
+
765
775
copy (function_call, FUNCTION_CALL, dest);
766
776
767
777
return ;
@@ -1435,6 +1445,16 @@ void goto_convertt::do_function_call_symbol(
1435
1445
code_function_callt function_call (lhs, function, arguments);
1436
1446
function_call.add_source_location ()=function.source_location ();
1437
1447
1448
+ // remove void-typed assignments, which may have been created when the
1449
+ // front-end was unable to detect them in type checking for a lack of
1450
+ // available declarations
1451
+ if (
1452
+ lhs.is_not_nil () &&
1453
+ to_code_type (symbol->type ).return_type ().id () == ID_empty)
1454
+ {
1455
+ function_call.lhs ().make_nil ();
1456
+ }
1457
+
1438
1458
copy (function_call, FUNCTION_CALL, dest);
1439
1459
}
1440
1460
}
Original file line number Diff line number Diff line change @@ -175,10 +175,10 @@ bool remove_returnst::do_function_calls(
175
175
optionalt<symbol_exprt> return_value;
176
176
177
177
if (!is_stub)
178
- {
179
178
return_value = get_or_create_return_value_symbol (function_id);
180
- CHECK_RETURN (return_value.has_value ());
181
179
180
+ if (return_value.has_value ())
181
+ {
182
182
// The return type in the definition of the function may differ
183
183
// from the return type in the declaration. We therefore do a
184
184
// cast.
@@ -199,7 +199,7 @@ bool remove_returnst::do_function_calls(
199
199
// fry the previous assignment
200
200
i_it->call_lhs ().make_nil ();
201
201
202
- if (!is_stub )
202
+ if (return_value. has_value () )
203
203
{
204
204
goto_program.insert_after (
205
205
t_a,
You can’t perform that action at this time.
0 commit comments