Skip to content

Commit d3f9861

Browse files
author
Daniel Kroening
committed
fix Java member operator
1 parent 822db22 commit d3f9861

File tree

1 file changed

+20
-13
lines changed

1 file changed

+20
-13
lines changed

src/java_bytecode/java_bytecode_typecheck_expr.cpp

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -162,38 +162,45 @@ Function: java_bytecode_typecheckt::typecheck_expr_symbol
162162

163163
void java_bytecode_typecheckt::typecheck_expr_member(member_exprt &expr)
164164
{
165-
// the member might be in a parent class
165+
// The member might be in a parent class, which we resolve here.
166166
const irep_idt component_name=expr.get_component_name();
167167

168-
#if 0
169168
while(1)
170169
{
171-
// TODO handle vtables
170+
if(expr.struct_op().type().id()!=ID_struct)
171+
break; // give up
172+
172173
const struct_typet &struct_type=
173174
to_struct_type(ns.follow(expr.struct_op().type()));
174175

175176
if(struct_type.has_component(component_name))
176177
return; // done
177178

178179
// look at parent
179-
const struct_typet::componentst &components=struct_type.components();
180+
const struct_typet::componentst &components=
181+
struct_type.components();
180182

181183
if(components.empty())
182-
{
183-
#if 0
184-
warning().sourc_location=expr.source_location();
185-
warning() << "failed to find field `"
186-
<< component_name << "` in class hierarchy" << eom;
187-
#endif
188-
return;
189-
}
190-
184+
break; // give up
185+
191186
const struct_typet::componentt &c=components.front();
192187

193188
member_exprt m(expr.struct_op(), c.get_name(), c.type());
194189
m.add_source_location()=expr.source_location();
195190

196191
expr.struct_op()=m;
197192
}
193+
194+
#if 0
195+
warning().source_location=expr.source_location();
196+
warning() << "failed to find field `"
197+
<< component_name << "` in class hierarchy" << eom;
198+
#else
199+
warning_msg("failed to find field `"+
200+
id2string(component_name)+"` in class hierarchy");
198201
#endif
202+
203+
// We replace by a non-det of same type
204+
side_effect_expr_nondett nondet(expr.type());
205+
expr.swap(nondet);
199206
}

0 commit comments

Comments
 (0)