Skip to content

simple test for mismatching return types accross compilation units #3089

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 3, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions regression/cbmc/Linking7/return_type.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
CORE
return_type1.c
return_type2.c
^EXIT=0$
^SIGNAL=0$
^VERIFICATION SUCCESSFUL$
--
^warning: ignoring
--
Note issue #3081
13 changes: 13 additions & 0 deletions regression/cbmc/Linking7/return_type1.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#include <assert.h>

struct S
{
int i;
};

struct S *function();

int main()
{
assert(function() != 0);
}
10 changes: 10 additions & 0 deletions regression/cbmc/Linking7/return_type2.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
struct S
{
int i;
int j; // extra member
} some_var;

struct S *function()
{
return &some_var;
}
10 changes: 8 additions & 2 deletions src/goto-programs/remove_returns.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,13 @@ void remove_returnst::do_function_calls(
exprt rhs;

if(!is_stub)
rhs=return_value;
{
// The return type in the definition of the function may differ
// from the return type in the declaration. We therefore do a
// cast.
rhs = typecast_exprt::conditional_cast(
return_value, function_call.lhs().type());
}
else
rhs = side_effect_expr_nondett(
function_call.lhs().type(), i_it->source_location);
Expand All @@ -208,7 +214,7 @@ void remove_returnst::do_function_calls(
goto_programt::targett t_d=goto_program.insert_after(t_a);
t_d->make_dead();
t_d->source_location=i_it->source_location;
t_d->code=code_deadt(rhs);
t_d->code = code_deadt(return_value);
t_d->function=i_it->function;
}
}
Expand Down