File tree Expand file tree Collapse file tree 3 files changed +16
-16
lines changed
Expand file tree Collapse file tree 3 files changed +16
-16
lines changed Original file line number Diff line number Diff line change @@ -18,8 +18,7 @@ void cpp_typecheckt::typecheck_compound_bases(struct_typet &type)
1818 std::set<irep_idt> bases;
1919 std::set<irep_idt> vbases;
2020
21- irep_idt default_class_access=
22- type.get_bool (ID_C_class)?ID_private:ID_public;
21+ irep_idt default_class_access = type.default_access ();
2322
2423 irept::subt &bases_irep=type.add (ID_bases).get_sub ();
2524
Original file line number Diff line number Diff line change @@ -977,8 +977,7 @@ void cpp_typecheckt::typecheck_compound_body(symbolt &symbol)
977977 symbol.type .set (ID_name, symbol.name );
978978
979979 // default access
980- irep_idt access=
981- type.get_bool (ID_C_class)?ID_private:ID_public;
980+ irep_idt access = type.default_access ();
982981
983982 bool found_ctor=false ;
984983 bool found_dtor=false ;
@@ -1119,8 +1118,7 @@ void cpp_typecheckt::typecheck_compound_body(symbolt &symbol)
11191118 }
11201119
11211120 // Reset the access type
1122- access=
1123- type.get_bool (ID_C_class)?ID_private:ID_public;
1121+ access = type.default_access ();
11241122
11251123 // All the data members are now known.
11261124 // We now deal with the constructors that we are given.
Original file line number Diff line number Diff line change @@ -216,6 +216,19 @@ class struct_union_typet:public typet
216216
217217 irep_idt get_tag () const { return get (ID_tag); }
218218 void set_tag (const irep_idt &tag) { set (ID_tag, tag); }
219+
220+ // / A struct may be a class, where members may have access restrictions.
221+ bool is_class () const
222+ {
223+ return id () == ID_struct && get_bool (ID_C_class);
224+ }
225+
226+ // / Return the access specification for members where access has not been
227+ // / modified.
228+ irep_idt default_access () const
229+ {
230+ return is_class () ? ID_private : ID_public;
231+ }
219232};
220233
221234// / Check whether a reference to a typet is a \ref struct_union_typet.
@@ -313,16 +326,6 @@ class class_typet:public struct_typet
313326 return (methodst &)(add (ID_methods).get_sub ());
314327 }
315328
316- bool is_class () const
317- {
318- return get_bool (ID_C_class);
319- }
320-
321- irep_idt default_access () const
322- {
323- return is_class ()?ID_private:ID_public;
324- }
325-
326329 class baset :public exprt
327330 {
328331 public:
You can’t perform that action at this time.
0 commit comments