Skip to content

Commit 117a17c

Browse files
author
Daniel Kroening
committed
fix accesses to exprt::opX() in ansi-c/
This improves type safety.
1 parent b20cf69 commit 117a17c

11 files changed

+157
-269
lines changed

src/ansi-c/ansi_c_convert_type.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ void ansi_c_convert_typet::read_rec(const typet &type)
108108
const exprt &as_expr=
109109
static_cast<const exprt &>(static_cast<const irept &>(type));
110110
assert(as_expr.operands().size()==1);
111-
msc_based=as_expr.op0();
111+
msc_based = to_unary_expr(as_expr).op();
112112
}
113113
else if(type.id()==ID_custom_bv)
114114
{
@@ -217,7 +217,7 @@ void ansi_c_convert_typet::read_rec(const typet &type)
217217
{
218218
assert(it->operands().size()==1);
219219
aligned=true;
220-
alignment=it->op0();
220+
alignment = to_unary_expr(*it).op();
221221
}
222222
}
223223
}

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: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -628,8 +628,8 @@ void c_typecheck_baset::typecheck_declaration(
628628
if(declaration.get_is_static_assert())
629629
{
630630
assert(declaration.operands().size()==2);
631-
typecheck_expr(declaration.op0());
632-
typecheck_expr(declaration.op1());
631+
typecheck_expr(to_binary_expr(declaration).op0());
632+
typecheck_expr(to_binary_expr(declaration).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)