Skip to content

Commit e56e130

Browse files
tautschnigDaniel Kroening
authored and
Daniel Kroening
committed
Remove dead code around ID_function_call
Both bits of code would necessarily have triggered a failing invariant or an exception. We continue to fail an invariant (UNREACHABLE), but don't keep around the poorly maintained (dead) code.
1 parent 8c1ae4c commit e56e130

File tree

2 files changed

+5
-54
lines changed

2 files changed

+5
-54
lines changed

src/ansi-c/c_typecheck_expr.cpp

Lines changed: 4 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -916,43 +916,13 @@ void c_typecheck_baset::typecheck_side_effect_statement_expression(
916916

917917
expr.type()=op.type();
918918
}
919-
else if(last_statement==ID_function_call)
919+
else
920920
{
921-
// this is suspected to be dead
922-
UNREACHABLE;
923-
924-
// make the last statement an expression
925-
926-
code_function_callt &fc=to_code_function_call(last);
927-
928-
side_effect_expr_function_callt sideeffect(
929-
fc.function(),
930-
fc.arguments(),
931-
to_code_type(fc.function().type()).return_type(),
932-
fc.source_location());
921+
// we used to do this, but don't expect it any longer
922+
PRECONDITION(last_statement != ID_function_call);
933923

934-
expr.type()=sideeffect.type();
935-
936-
if(fc.lhs().is_nil())
937-
{
938-
code_expressiont code_expr(sideeffect);
939-
code_expr.add_source_location() = fc.source_location();
940-
last.swap(code_expr);
941-
}
942-
else
943-
{
944-
side_effect_exprt assign(
945-
ID_assign, sideeffect.type(), fc.source_location());
946-
assign.add_to_operands(fc.lhs(), std::move(sideeffect));
947-
948-
code_expressiont code_expr(assign);
949-
code_expr.add_source_location() = fc.source_location();
950-
951-
last.swap(code_expr);
952-
}
953-
}
954-
else
955924
expr.type()=typet(ID_empty);
925+
}
956926
}
957927

958928
void c_typecheck_baset::typecheck_expr_sizeof(exprt &expr)

src/goto-symex/symex_assign.cpp

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -40,26 +40,7 @@ void goto_symext::symex_assign(
4040
const side_effect_exprt &side_effect_expr=to_side_effect_expr(rhs);
4141
const irep_idt &statement=side_effect_expr.get_statement();
4242

43-
if(statement==ID_function_call)
44-
{
45-
const auto &function_call =
46-
to_side_effect_expr_function_call(side_effect_expr);
47-
48-
DATA_INVARIANT(
49-
!side_effect_expr.operands().empty(),
50-
"function call statement expects non-empty list of side effects");
51-
52-
DATA_INVARIANT(
53-
function_call.function().id() == ID_symbol,
54-
"expected symbol as function");
55-
56-
const irep_idt &identifier =
57-
to_symbol_expr(function_call.function()).get_identifier();
58-
59-
throw unsupported_operation_exceptiont(
60-
"symex_assign: unexpected function call: " + id2string(identifier));
61-
}
62-
else if(
43+
if(
6344
statement == ID_cpp_new || statement == ID_cpp_new_array ||
6445
statement == ID_java_new_array_data)
6546
symex_cpp_new(state, lhs, side_effect_expr);

0 commit comments

Comments
 (0)