@@ -162,38 +162,45 @@ Function: java_bytecode_typecheckt::typecheck_expr_symbol
162
162
163
163
void java_bytecode_typecheckt::typecheck_expr_member (member_exprt &expr)
164
164
{
165
- // the member might be in a parent class
165
+ // The member might be in a parent class, which we resolve here.
166
166
const irep_idt component_name=expr.get_component_name ();
167
167
168
- #if 0
169
168
while (1 )
170
169
{
171
- // TODO handle vtables
170
+ if (expr.struct_op ().type ().id ()!=ID_struct)
171
+ break ; // give up
172
+
172
173
const struct_typet &struct_type=
173
174
to_struct_type (ns.follow (expr.struct_op ().type ()));
174
175
175
176
if (struct_type.has_component (component_name))
176
177
return ; // done
177
178
178
179
// look at parent
179
- const struct_typet::componentst &components=struct_type.components();
180
+ const struct_typet::componentst &components=
181
+ struct_type.components ();
180
182
181
183
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
+
191
186
const struct_typet::componentt &c=components.front ();
192
187
193
188
member_exprt m (expr.struct_op (), c.get_name (), c.type ());
194
189
m.add_source_location ()=expr.source_location ();
195
190
196
191
expr.struct_op ()=m;
197
192
}
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" );
198
201
#endif
202
+
203
+ // We replace by a non-det of same type
204
+ side_effect_expr_nondett nondet (expr.type ());
205
+ expr.swap (nondet);
199
206
}
0 commit comments