@@ -117,7 +117,59 @@ class goto_functiont
117
117
// / reported via DATA_INVARIANT violations or exceptions.
118
118
void validate (const namespacet &ns, const validation_modet vm) const
119
119
{
120
- body.validate (ns, vm);
120
+ auto type_symbol_finder =
121
+ [&](const typet &t, const source_locationt &location) {
122
+ irep_idt identifier = ID_nil;
123
+ if (t.id () == ID_symbol_type)
124
+ {
125
+ identifier = to_symbol_type (t).get_identifier ();
126
+ }
127
+ else if (
128
+ t.id () == ID_c_enum_tag || t.id () == ID_struct_tag ||
129
+ t.id () == ID_union_tag)
130
+ {
131
+ identifier = to_tag_type (t).get_identifier ();
132
+ }
133
+ if (identifier != ID_nil)
134
+ {
135
+ const symbolt *symbol;
136
+ if (location.is_nil ())
137
+ DATA_CHECK (
138
+ !ns.lookup (identifier, symbol),
139
+ id2string (identifier) + " not found" );
140
+ else
141
+ DATA_CHECK_WITH_DIAGNOSTICS (
142
+ !ns.lookup (identifier, symbol),
143
+ id2string (identifier) + " not found" ,
144
+ location);
145
+ }
146
+ };
147
+
148
+ auto expr_symbol_finder =
149
+ [&](const exprt &e, const source_locationt &location) {
150
+ forall_subtypes (it, e.type ())
151
+ {
152
+ type_symbol_finder (*it, location);
153
+ }
154
+ if (e.id () == ID_symbol)
155
+ {
156
+ const symbolt *symbol;
157
+ auto identifier = to_symbol_expr (e).get_identifier ();
158
+ DATA_CHECK_WITH_DIAGNOSTICS (
159
+ !ns.lookup (identifier, symbol),
160
+ id2string (identifier) + " not found" ,
161
+ location);
162
+ }
163
+ };
164
+
165
+ body.validate (expr_symbol_finder, ns, vm);
166
+ source_locationt nil_location;
167
+ nil_location.make_nil ();
168
+ forall_subtypes (it, type)
169
+ {
170
+ type_symbol_finder (*it, nil_location);
171
+ }
172
+
121
173
validate_full_type (type, ns, vm);
122
174
}
123
175
};
0 commit comments