File tree 5 files changed +22
-16
lines changed
5 files changed +22
-16
lines changed Original file line number Diff line number Diff line change @@ -104,10 +104,15 @@ symbolt &cpp_declarator_convertert::convert(
104
104
{
105
105
// adjust type if it's a non-static member function
106
106
if (final_type.id ()==ID_code)
107
+ {
108
+ cpp_save_scopet save_scope (cpp_typecheck.cpp_scopes );
109
+ cpp_typecheck.cpp_scopes .go_to (*scope);
110
+
107
111
cpp_typecheck.add_this_to_method_type (
108
112
cpp_typecheck.lookup (scope->identifier ),
109
113
to_code_type (final_type),
110
114
method_qualifier);
115
+ }
111
116
112
117
get_final_identifier ();
113
118
Original file line number Diff line number Diff line change @@ -54,10 +54,10 @@ void cpp_typecheckt::typecheck()
54
54
for (auto &item : cpp_parse_tree.items )
55
55
convert (item);
56
56
57
- typecheck_method_bodies ();
58
-
59
57
static_and_dynamic_initialization ();
60
58
59
+ typecheck_method_bodies ();
60
+
61
61
do_not_typechecked ();
62
62
63
63
clean_up ();
@@ -276,13 +276,10 @@ void cpp_typecheckt::clean_up()
276
276
277
277
const symbolt &symbol=cur_it->second ;
278
278
279
- // erase templates
280
- if (symbol.type .get_bool (ID_is_template) ||
281
- // Remove all symbols that have not been converted.
282
- // In particular this includes symbols created for functions
283
- // during template instantiation that are never called,
284
- // and hence, their bodies have not been converted.
285
- contains_cpp_name (symbol.value ))
279
+ // erase templates and all member functions that have not been converted
280
+ if (
281
+ symbol.type .get_bool (ID_is_template) ||
282
+ deferred_typechecking.find (symbol.name ) != deferred_typechecking.end ())
286
283
{
287
284
symbol_table.erase (cur_it);
288
285
continue ;
Original file line number Diff line number Diff line change 12
12
#ifndef CPROVER_CPP_CPP_TYPECHECK_H
13
13
#define CPROVER_CPP_CPP_TYPECHECK_H
14
14
15
- #include < cassert>
16
- #include < set>
17
15
#include < list>
18
16
#include < map>
17
+ #include < set>
18
+ #include < unordered_set>
19
19
20
20
#include < util/std_code.h>
21
21
#include < util/std_types.h>
@@ -588,6 +588,7 @@ class cpp_typecheckt:public c_typecheck_baset
588
588
typedef std::list<irep_idt> dynamic_initializationst;
589
589
dynamic_initializationst dynamic_initializations;
590
590
bool disable_access_control; // Disable protect and private
591
+ std::unordered_set<irep_idt> deferred_typechecking;
591
592
};
592
593
593
594
#endif // CPROVER_CPP_CPP_TYPECHECK_H
Original file line number Diff line number Diff line change @@ -1335,8 +1335,7 @@ void cpp_typecheckt::typecheck_member_function(
1335
1335
// Is this in a class template?
1336
1336
// If so, we defer typechecking until used.
1337
1337
if (cpp_scopes.current_scope ().get_parent ().is_template_scope ())
1338
- {
1339
- }
1338
+ deferred_typechecking.insert (new_symbol->name );
1340
1339
else // remember for later typechecking of body
1341
1340
add_method_body (new_symbol);
1342
1341
}
@@ -1360,9 +1359,11 @@ void cpp_typecheckt::add_this_to_method_type(
1360
1359
subtype.set (ID_C_volatile, true );
1361
1360
1362
1361
code_typet::parametert parameter (pointer_type (subtype));
1363
- parameter.set_identifier (ID_this); // check? Not qualified
1362
+ parameter.set_identifier (ID_this);
1364
1363
parameter.set_base_name (ID_this);
1365
1364
parameter.set_this ();
1365
+ if (!cpp_scopes.current_scope ().get_parent ().is_template_scope ())
1366
+ convert_parameter (compound_symbol.mode , parameter);
1366
1367
1367
1368
code_typet::parameterst ¶meters = type.parameters ();
1368
1369
parameters.insert (parameters.begin (), parameter);
Original file line number Diff line number Diff line change @@ -31,6 +31,7 @@ void cpp_typecheckt::convert_parameter(
31
31
parameter.set_base_name (base_name);
32
32
}
33
33
34
+ PRECONDITION (!cpp_scopes.current_scope ().prefix .empty ());
34
35
irep_idt identifier=cpp_scopes.current_scope ().prefix +
35
36
id2string (base_name);
36
37
@@ -147,6 +148,8 @@ void cpp_typecheckt::convert_function(symbolt &symbol)
147
148
symbol.value .type ()=symbol.type ;
148
149
149
150
return_type = old_return_type;
151
+
152
+ deferred_typechecking.erase (symbol.name );
150
153
}
151
154
152
155
// / for function overloading
@@ -171,8 +174,7 @@ irep_idt cpp_typecheckt::function_identifier(const typet &type)
171
174
code_typet::parameterst::const_iterator it=
172
175
parameters.begin ();
173
176
174
- if (it!=parameters.end () &&
175
- it->get_identifier ()==ID_this)
177
+ if (it != parameters.end () && it->get_base_name () == ID_this)
176
178
{
177
179
const typet &pointer=it->type ();
178
180
const typet &symbol =pointer.subtype ();
You can’t perform that action at this time.
0 commit comments