Go to the documentation of this file.
35 const irep_idt &name=it->get(ID_name);
37 if(it->find(ID_value).is_not_nil())
39 exprt &value=
static_cast<exprt &
>(it->add(ID_value));
46 error() <<
"failed to produce integer for enum constant" <<
eom;
52 value_expr.
type()=enum_tag_type;
58 symbol.
value=value_expr;
63 symbol.
type=enum_tag_type;
71 error() <<
"cpp_typecheckt::typecheck_enum_body: "
72 <<
"symbol_table.move() failed" <<
eom;
89 qualifiers.
read(type);
92 bool anonymous=!enum_type.
has_tag();
117 tag_scope(base_name, has_body, tag_only_declaration);
124 symbol_tablet::symbolst::const_iterator previous_symbol=
131 const symbolt &symbol=previous_symbol->second;
136 error() <<
"error: enum symbol `" << base_name
137 <<
"' declared previously\n"
138 <<
"location of previous definition: "
147 std::string pretty_name=
165 error() <<
"underlying type must be integral" <<
eom;
172 symbol.
name=symbol_name;
188 error() <<
"cpp_typecheckt::typecheck_enum_type: "
189 <<
"symbol_table.move() failed" <<
eom;
211 error() <<
"use of enum `" << base_name
212 <<
"' without previous declaration" <<
eom;
218 qualifiers.
write(type);
virtual void read(const typet &src) override
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
const typet & subtype() const
cpp_scopet & tag_scope(const irep_idt &_base_name, bool has_body, bool tag_only_declaration)
const cpp_enum_typet & to_cpp_enum_type(const irept &irep)
const c_enum_typet & to_c_enum_type(const typet &type)
Cast a typet to a c_enum_typet.
The type of an expression, extends irept.
typet type
Type of symbol.
irept & add(const irep_namet &name)
Base class for all expressions.
irep_idt base_name
Base (non-scoped) name.
struct configt::ansi_ct ansi_c
cpp_idt & put_into_scope(const symbolt &symbol, cpp_scopet &scope, bool is_friend=false)
#define Forall_irep(it, irep)
irep_idt pretty_name
Language-specific display name.
virtual void make_constant(exprt &expr)
bool get_tag_only_declaration() const
typet & type()
Return the type of the expression.
void typecheck_type(typet &) override
bool get_bool(const irep_namet &name) const
irep_idt generate_anon_tag() const
irep_idt mode
Language mode.
signedbv_typet signed_int_type()
const std::string & id2string(const irep_idt &d)
cpp_scopet & current_scope()
source_locationt source_location
const source_locationt & source_location() const
const source_locationt & find_source_location() const
Get a source_locationt from the expression or from its operands (non-recursively).
virtual void write(typet &src) const override
symbol_tablet & symbol_table
const irep_idt & id() const
virtual bool move(symbolt &symbol, symbolt *&new_symbol) override
Move a symbol into the symbol table.
void typecheck_expr(exprt &) override
exprt value
Initial value of symbol.
C enum tag type, i.e., c_enum_typet with an identifier.
void typecheck_enum_body(symbolt &symbol)
cpp_scopet & resolve_scope(const cpp_namet &cpp_name, irep_idt &base_name, cpp_template_args_non_tct &template_args)
source_locationt location
Source code location of definition of symbol.
const cpp_namet & tag() const
void implicit_typecast(exprt &expr, const typet &type) override
void typecheck_enum_type(typet &type)
irep_idt module
Name of module the symbol belongs to.
std::vector< irept > subt
irep_idt name
The unique identifier.