34 const irep_idt &name=it->get(ID_name);
36 if(it->find(ID_value).is_not_nil())
38 exprt &value=
static_cast<exprt &
>(it->add(ID_value));
45 error() <<
"failed to produce integer for enum constant" <<
eom;
51 value_expr.
type()=enum_tag_type;
57 symbol.
value=value_expr;
62 symbol.
type=enum_tag_type;
70 error() <<
"cpp_typecheckt::typecheck_enum_body: " 71 <<
"symbol_table.move() failed" <<
eom;
88 qualifiers.
read(type);
91 bool anonymous=!enum_type.
has_tag();
108 error() <<
"enum tag is expected to be a simple name" <<
eom;
117 tag_scope(base_name, has_body, tag_only_declaration);
124 symbol_tablet::symbolst::iterator previous_symbol=
131 symbolt &symbol=previous_symbol->second;
136 error() <<
"error: enum symbol `" << base_name
137 <<
"' declared previously\n" 138 <<
"location of previous definition: " 145 std::string pretty_name=
163 error() <<
"underlying type must be integral" <<
eom;
170 symbol.
name=symbol_name;
186 error() <<
"cpp_typecheckt::typecheck_enum_type: " 187 <<
"symbol_table.move() failed" <<
eom;
202 error() <<
"use of enum `" << base_name
203 <<
"' without previous declaration" <<
eom;
209 qualifiers.
write(type);
The type of an expression.
irep_idt name
The unique identifier.
void typecheck_type(typet &type)
irep_idt generate_anon_tag() const
const std::string & id2string(const irep_idt &d)
std::vector< irept > subt
virtual void make_constant(exprt &expr)
irep_idt mode
Language mode.
exprt value
Initial value of symbol.
cpp_idt & put_into_scope(const symbolt &symbol, cpp_scopet &scope, bool is_friend=false)
bool get_tag_only_declaration() const
void typecheck_enum_body(symbolt &symbol)
irep_idt module
Name of module the symbol belongs to.
irep_idt pretty_name
Language-specific display name.
bool is_simple_name() const
virtual void implicit_typecast(exprt &expr, const typet &type)
Symbol table entry.This is a symbol in the symbol table, stored in an object of type symbol_tablet...
static mstreamt & eom(mstreamt &m)
virtual void typecheck_expr(exprt &expr)
const cpp_namet & tag() const
symbol_tablet & symbol_table
void typecheck_enum_type(typet &type)
void read(const typet &src)
const irep_idt & id() const
const c_enum_typet & to_c_enum_type(const typet &type)
Cast a generic typet to a c_enum_typet.
const source_locationt & find_source_location() const
source_locationt source_location
void write(typet &src) const
C++ Language Type Checking.
C++ Language Type Checking.
#define Forall_irep(it, irep)
const cpp_enum_typet & to_cpp_enum_type(const irept &irep)
bool move(symbolt &symbol, symbolt *&new_symbol)
Move a symbol into the symbol table.
const source_locationt & source_location() const
irep_idt get_base_name() const
typet type
Type of symbol.
source_locationt location
Source code location of definition of symbol.
Base class for all expressions.
irep_idt base_name
Base (non-scoped) name.
cpp_scopet & current_scope()
irept & add(const irep_namet &name)
signedbv_typet signed_int_type()
const typet & subtype() const
cpp_scopet & tag_scope(const irep_idt &_base_name, bool has_body, bool tag_only_declaration)