@@ -180,8 +180,9 @@ gen_clinit_eqexpr(const exprt &expr, const clinit_statest state)
180
180
181
181
// / Generates codet that iterates through the base types of the class specified
182
182
// / by class_name, C, and recursively adds calls to their clinit wrapper.
183
- // / Finally a call to the clinit of C is made or if nondet-static option was
184
- // / given then all static variables of the class are nondet-initialized instead.
183
+ // / Finally a call to the clinit of C is made. If nondet-static option was
184
+ // / given then all static variables that are not constants (i.e. final) are
185
+ // / then re-assigned to a nondet value.
185
186
// / \param symbol_table: symbol table
186
187
// / \param class_name: name of the class to generate clinit wrapper calls for
187
188
// / \param [out] init_body: appended with calls to clinit wrapper
@@ -216,26 +217,24 @@ static void clinit_wrapper_do_recursive_calls(
216
217
auto find_sym_it = symbol_table.symbols .find (real_clinit_name);
217
218
if (find_sym_it != symbol_table.symbols .end ())
218
219
{
219
- if (!nondet_static)
220
+ code_function_callt call_real_init;
221
+ call_real_init.function () = find_sym_it->second .symbol_expr ();
222
+ init_body.move_to_operands (call_real_init);
223
+
224
+ // Add a standard nondet initialisation for each global declared on this
225
+ // class. Note this is the same invocation used in
226
+ // get_stub_initializer_body and java_static_lifetime_init.
227
+ if (nondet_static)
220
228
{
221
- code_function_callt call_real_init;
222
- call_real_init.function () = find_sym_it->second .symbol_expr ();
223
- init_body.move_to_operands (call_real_init);
224
- }
225
- else
226
- {
227
- // Add a standard nondet initialisation for each global declared on this
228
- // class. Note this is the same invocation used in
229
- // get_stub_initializer_body and java_static_lifetime_init.
230
-
231
229
object_factory_parameterst parameters = object_factory_parameters;
232
230
parameters.function_id = clinit_wrapper_name (class_name);
233
231
234
232
for (const auto &symbol : symbol_table.symbols )
235
233
{
236
234
if (
235
+ symbol.second .type .get (ID_C_class) == class_name &&
237
236
symbol.second .is_static_lifetime &&
238
- symbol.second .type .get (ID_C_class) == class_name )
237
+ ! symbol.second .type .get_bool (ID_C_constant) )
239
238
{
240
239
const symbol_exprt new_global_symbol = symbol.second .symbol_expr ();
241
240
0 commit comments