Skip to content

Commit 33c00c1

Browse files
authored
Merge pull request #4983 from diffblue/ansi-c-opX
fix accesses to exprt::opX() in ansi-c/
2 parents 3af0130 + 9ae4c37 commit 33c00c1

12 files changed

+245
-313
lines changed

src/ansi-c/ansi_c_convert_type.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,7 @@ void ansi_c_convert_typet::read_rec(const typet &type)
107107
{
108108
const exprt &as_expr=
109109
static_cast<const exprt &>(static_cast<const irept &>(type));
110-
assert(as_expr.operands().size()==1);
111-
msc_based=as_expr.op0();
110+
msc_based = to_unary_expr(as_expr).op();
112111
}
113112
else if(type.id()==ID_custom_bv)
114113
{
@@ -215,9 +214,8 @@ void ansi_c_convert_typet::read_rec(const typet &type)
215214
c_storage_spec.is_thread_local=true;
216215
else if(id=="align")
217216
{
218-
assert(it->operands().size()==1);
219217
aligned=true;
220-
alignment=it->op0();
218+
alignment = to_unary_expr(*it).op();
221219
}
222220
}
223221
}

src/ansi-c/ansi_c_language.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,9 @@ bool ansi_c_languaget::to_expr(
214214
if(expr.id()==ID_typecast &&
215215
expr.type().id()==ID_empty &&
216216
expr.operands().size()==1)
217-
expr=expr.op0();
217+
{
218+
expr = to_typecast_expr(expr).op();
219+
}
218220

219221
return result;
220222
}

src/ansi-c/c_typecheck_base.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -627,9 +627,9 @@ void c_typecheck_baset::typecheck_declaration(
627627
{
628628
if(declaration.get_is_static_assert())
629629
{
630-
assert(declaration.operands().size()==2);
631-
typecheck_expr(declaration.op0());
632-
typecheck_expr(declaration.op1());
630+
auto &static_assert_expr = to_binary_expr(declaration);
631+
typecheck_expr(static_assert_expr.op0());
632+
typecheck_expr(static_assert_expr.op1());
633633
}
634634
else
635635
{

src/ansi-c/c_typecheck_base.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ class c_typecheck_baset:
177177
virtual void typecheck_expr_ptrmember(exprt &expr);
178178
virtual void typecheck_expr_rel(binary_relation_exprt &expr);
179179
virtual void typecheck_expr_rel_vector(binary_relation_exprt &expr);
180-
virtual void adjust_float_rel(exprt &expr);
180+
virtual void adjust_float_rel(binary_relation_exprt &);
181181
static void add_rounding_mode(exprt &);
182182
virtual void typecheck_expr_index(exprt &expr);
183183
virtual void typecheck_expr_typecast(exprt &expr);

src/ansi-c/c_typecheck_code.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -567,9 +567,7 @@ void c_typecheck_baset::typecheck_gcc_computed_goto(codet &code)
567567
throw 0;
568568
}
569569

570-
assert(dest.operands().size()==1);
571-
572-
typecheck_expr(dest.op0());
570+
typecheck_expr(to_unary_expr(dest).op());
573571
dest.type() = void_type();
574572
}
575573

0 commit comments

Comments
 (0)