20 std::set<irep_idt> bases;
21 std::set<irep_idt> vbases;
27 for(
auto &base : bases_irep)
31 exprt base_symbol_expr=
37 if(base_symbol_expr.
id()!=ID_type)
40 error() <<
"expected type as struct/class base" <<
eom;
47 if(base_symbol_expr.
type().
id() != ID_struct_tag)
50 error() <<
"expected type symbol as struct/class base" <<
eom;
57 if(base_symbol.
type.
id() != ID_struct)
60 error() <<
"expected struct or class as base, but got '"
68 error() <<
"base type is incomplete" <<
eom;
72 bool virtual_base = base.get_bool(ID_virtual);
73 irep_idt class_access = base.get(ID_protection);
75 if(class_access.
empty())
76 class_access = default_class_access;
78 base_symbol_expr.
id(ID_base);
79 base_symbol_expr.
set(ID_access, class_access);
82 base_symbol_expr.
set(ID_virtual,
true);
84 base.swap(base_symbol_expr);
123 std::set<irep_idt> &bases,
124 std::set<irep_idt> &vbases,
129 if(is_virtual && vbases.find(from_name)!=vbases.end())
132 if(bases.find(from_name)!=bases.end())
135 error() <<
"non-virtual base class " << from_name
136 <<
" inherited multiple times" <<
eom;
140 bases.insert(from_name);
143 vbases.insert(from_name);
146 for(
const auto &b : from.
bases())
148 irep_idt sub_access = b.get(ID_access);
150 if(access==ID_private)
151 sub_access=ID_private;
152 else if(access==ID_protected && sub_access!=ID_private)
153 sub_access=ID_protected;
157 const bool is_virtual_base = b.get_bool(ID_virtual);
174 if(c.get_bool(ID_from_base))
186 if(access==ID_public)
188 if(comp_access==ID_private)
191 else if(access == ID_protected)
193 if(comp_access==ID_private)
198 else if(access == ID_private)
200 if(comp_access == ID_noaccess || comp_access == ID_private)
const source_locationt & source_location() const
cpp_scopet & current_scope()
void add_secondary_scope(cpp_scopet &other)
void put_compound_into_scope(const struct_union_typet::componentt &component)
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)
void typecheck_compound_bases(struct_typet &type)
void elaborate_class_template(const typet &type)
elaborate class template instances
std::string to_string(const typet &) override
exprt resolve(const cpp_namet &cpp_name, const cpp_typecheck_resolvet::wantt want, const cpp_typecheck_fargst &fargs, bool fail_with_exception=true)
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
Base class for all expressions.
source_locationt & add_source_location()
typet & type()
Return the type of the expression.
const irep_idt & get(const irep_idt &name) const
void set(const irep_idt &name, const irep_idt &value)
const irep_idt & id() const
irept & add(const irep_idt &name)
source_locationt source_location
const symbolt & lookup(const irep_idt &name) const
Lookup a symbol in the namespace.
Structure type, corresponds to C style structs.
const basest & bases() const
Get the collection of base classes/structs.
void set_pretty_name(const irep_idt &name)
void set_base_name(const irep_idt &base_name)
void set_access(const irep_idt &access)
irep_idt default_access() const
Return the access specification for members where access has not been modified.
bool is_incomplete() const
A struct/union may be incomplete.
const componentst & components() const
std::vector< componentt > componentst
typet type
Type of symbol.
irep_idt name
The unique identifier.
const source_locationt & source_location() const
cpp_namet & to_cpp_name(irept &cpp_name)
C++ Language Type Checking.
C++ Language Type Checking.
#define UNREACHABLE
This should be used to mark dead code.
auto component(T &struct_expr, const irep_idt &name, const namespacet &ns) -> decltype(struct_expr.op0())
const struct_typet & to_struct_type(const typet &type)
Cast a typet to a struct_typet.
const struct_tag_typet & to_struct_tag_type(const typet &type)
Cast a typet to a struct_tag_typet.