@@ -23,9 +23,9 @@ static std::function<bool(const typet &)> is_type(const typet &t1)
23
23
return f;
24
24
}
25
25
26
- SCENARIO (" has_subtype" , " [core][solvers][refinement][string_refinement ]" )
26
+ SCENARIO (" has_subtype" , " [core][utils][has_subtype ]" )
27
27
{
28
- const symbol_tablet symbol_table;
28
+ symbol_tablet symbol_table;
29
29
const namespacet ns (symbol_table);
30
30
31
31
const typet char_type = java_char_type ();
@@ -63,4 +63,32 @@ SCENARIO("has_subtype", "[core][solvers][refinement][string_refinement]")
63
63
REQUIRE_FALSE (has_subtype (ptr_type, is_type (int_type), ns));
64
64
}
65
65
}
66
+
67
+ GIVEN (" a recursive struct definition" )
68
+ {
69
+ symbol_typet symbol_type (" A-struct" );
70
+ struct_typet::componentt comp (" ptr" , pointer_type (symbol_type));
71
+ struct_typet struct_type;
72
+ struct_type.components ().push_back (comp);
73
+
74
+ symbolt s;
75
+ s.type = struct_type;
76
+ s.name = " A-struct" ;
77
+ s.is_type = true ;
78
+ symbol_table.add (s);
79
+
80
+ THEN (" has_subtype terminates" )
81
+ {
82
+ REQUIRE_FALSE (
83
+ has_subtype (struct_type, [&](const typet &t) { return false ; }, ns));
84
+ }
85
+ THEN (" symbol type is a subtype" )
86
+ {
87
+ REQUIRE (has_subtype (struct_type, is_type (pointer_type (symbol_type)), ns));
88
+ }
89
+ THEN (" struct type is a subtype" )
90
+ {
91
+ REQUIRE (has_subtype (struct_type, is_type (struct_type), ns));
92
+ }
93
+ }
66
94
}
0 commit comments