Go to the documentation of this file.
18 std::set<irep_idt> bases;
19 std::set<irep_idt> vbases;
30 exprt base_symbol_expr=
36 if(base_symbol_expr.
id()!=ID_type)
39 error() <<
"expected type as struct/class base" <<
eom;
46 if(base_symbol_expr.
type().
id() == ID_symbol_type)
47 base_symbol_expr.
type().
id(ID_struct_tag);
49 if(base_symbol_expr.
type().
id() != ID_struct_tag)
52 error() <<
"expected type symbol as struct/class base" <<
eom;
59 if(base_symbol.
type.
id()==ID_incomplete_struct)
62 error() <<
"base type is incomplete" <<
eom;
65 else if(base_symbol.
type.
id()!=ID_struct)
68 error() <<
"expected struct or class as base, but got `"
73 bool virtual_base = base_it->get_bool(ID_virtual);
74 irep_idt class_access = base_it->get(ID_protection);
76 if(class_access.
empty())
77 class_access = default_class_access;
79 base_symbol_expr.
id(ID_base);
80 base_symbol_expr.
set(ID_access, class_access);
83 base_symbol_expr.
set(ID_virtual,
true);
85 base_it->swap(base_symbol_expr);
124 std::set<irep_idt> &bases,
125 std::set<irep_idt> &vbases,
130 if(is_virtual && vbases.find(from_name)!=vbases.end())
133 if(bases.find(from_name)!=bases.end())
136 error() <<
"error: non-virtual base class " << from_name
137 <<
" inherited multiple times" <<
eom;
141 bases.insert(from_name);
144 vbases.insert(from_name);
147 for(
const auto &b : from.
bases())
149 irep_idt sub_access = b.get(ID_access);
151 if(access==ID_private)
152 sub_access=ID_private;
153 else if(access==ID_protected && sub_access!=ID_private)
154 sub_access=ID_protected;
158 const bool is_virtual_base = b.get_bool(ID_virtual);
175 if(c.get_bool(ID_from_base))
187 if(access==ID_public)
189 if(comp_access==ID_private)
192 else if(access == ID_protected)
194 if(comp_access==ID_private)
199 else if(access == ID_private)
201 if(comp_access == ID_noaccess || comp_access == ID_private)
const componentst & components() const
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
void elaborate_class_template(const typet &type)
elaborate class template instances
void add_base_components(const struct_typet &from, const irep_idt &access, struct_typet &to, std::set< irep_idt > &bases, std::set< irep_idt > &vbases, bool is_virtual)
const struct_typet & to_struct_type(const typet &type)
Cast a typet to a struct_typet.
void set_access(const irep_idt &access)
typet type
Type of symbol.
irept & add(const irep_namet &name)
void typecheck_compound_bases(struct_typet &type)
Base class for all expressions.
std::vector< componentt > componentst
auto component(T &struct_expr, const irep_idt &name, const namespacet &ns) -> decltype(struct_expr.op0())
irep_idt default_access() const
Return the access specification for members where access has not been modified.
#define Forall_irep(it, irep)
#define UNREACHABLE
This should be used to mark dead code.
typet & type()
Return the type of the expression.
bool lookup(const irep_idt &name, const symbolt *&symbol) const override
See documentation for namespace_baset::lookup().
void add_secondary_scope(cpp_scopet &other)
cpp_scopet & current_scope()
source_locationt source_location
const source_locationt & source_location() const
void set_pretty_name(const irep_idt &name)
void set_base_name(const irep_idt &base_name)
const basest & bases() const
Get the collection of base classes/structs.
void put_compound_into_scope(const struct_union_typet::componentt &component)
const irep_idt & id() const
const struct_tag_typet & to_struct_tag_type(const typet &type)
Cast a typet to a struct_tag_typet.
Structure type, corresponds to C style structs.
const source_locationt & source_location() const
const irep_idt & get(const irep_namet &name) const
void set(const irep_namet &name, const irep_idt &value)
std::string to_string(const typet &) override
source_locationt & add_source_location()
exprt resolve(const cpp_namet &cpp_name, const cpp_typecheck_resolvet::wantt want, const cpp_typecheck_fargst &fargs, bool fail_with_exception=true)
std::vector< irept > subt
irep_idt name
The unique identifier.
cpp_namet & to_cpp_name(irept &cpp_name)