26 is_template_parameter(false),
28 linkage_spec(_cpp_typecheck.current_linkage_spec),
34 const typet &declaration_type,
41 if(declaration_type.
id()==
"cpp-cast-operator")
53 assert(declarator.
id()==ID_cpp_declarator);
55 assert(final_type.is_not_nil());
87 typet &method_qualifier=
91 if(final_type.id()==ID_template)
95 tmp.
swap(final_type.subtype());
100 symbol_tablet::symbolst::iterator c_it=
106 if(final_type.id()==ID_code)
120 <<
"' not found in scope `" 136 if(final_type.get(ID_return_type)==ID_constructor)
146 if(symbol_expr.
id()!=ID_type ||
147 symbol_expr.
type().
id()!=ID_symbol)
158 assert(type.
id()==ID_struct);
160 if(declarator.
find(ID_member_initializers).
is_nil())
161 declarator.
set(ID_member_initializers, ID_member_initializers);
174 symbol.is_extern=
false;
186 if(final_type.id()==ID_code &&
196 symbol_tablet::symbolst::iterator c_it=
207 if(declarator.
get_bool(
"#template_case"))
216 if(symbol.
type.
id()==
"cpp-template-type")
237 const typet &decl_type,
240 if(symbol.
type.
id()==decl_type.
id() &&
241 decl_type.
id()==ID_code)
254 for(
unsigned i=0; i<decl_code_type.
parameters().size(); i++)
262 if(decl_parameter.
type()!=symbol_parameter.
type())
265 if(i!=0 || !symbol_code_type.
get_bool(
"#is_virtual"))
269 <<
"': parameter " << (i+1)
270 <<
" type mismatch\n" 273 symbol_parameter.
type())
276 decl_parameter.
type())
295 else if(symbol.
type==decl_type)
297 else if(symbol.
type.
id()==ID_array &&
299 decl_type.
id()==ID_array &&
302 symbol.
type = decl_type;
308 <<
"' already declared with different type:\n" 367 <<
"' has already been defined";
371 <<
"' already has an initializer";
401 symbol_tablet::symbolst::const_iterator
405 c_it->second.type.id()==ID_code &&
450 symbol.
type.
set(ID_C_inlined,
true);
467 symbol.
value.
id() == ID_constant);
504 <<
"cpp_typecheckt::convert_declarator: symbol_table.move() failed" 516 for(cpp_scopest::id_sett::const_iterator
517 id_it=id_set.begin();
525 if(!
id.is_class() && !
id.is_enum())
529 <<
"' already in scope" 575 const typet ¶meter_type=((
exprt &)*it).type();
577 if(it!=parameters.begin())
599 if(symbol.
name==ID_main)
601 if(symbol.
type.
id()!=ID_code)
608 const typet &return_type=
616 throw "main must return int";
C++ Language Type Checking.
The type of an expression.
irep_idt name
The unique identifier.
void main_function_rules(const symbolt &symbol)
void check_fixed_size_array(typet &type)
check that an array has fixed size
void get_final_identifier()
virtual bool lookup(const irep_idt &name, const symbolt *&symbol) const
void typecheck_type(typet &type)
const std::string & id2string(const irep_idt &d)
std::set< cpp_idt * > id_sett
class cpp_typecheckt & cpp_typecheck
void lookup(const irep_idt &base_name, lookup_kindt kind, id_sett &id_set)
std::vector< irept > subt
irep_idt mode
Language mode.
bool is_code_type(const typet &type) const
void full_member_initialization(const struct_union_typet &struct_union_type, irept &initializers)
Build the full initialization list of the constructor.
exprt value
Initial value of symbol.
const componentst & components() const
cpp_idt & put_into_scope(const symbolt &symbol, cpp_scopet &scope, bool is_friend=false)
irep_idt module
Name of module the symbol belongs to.
irep_idt pretty_name
Language-specific display name.
bool cpp_typecheck(cpp_parse_treet &cpp_parse_tree, symbol_tablet &symbol_table, const std::string &module, message_handlert &message_handler)
void move_member_initializers(irept &initializers, const typet &type, exprt &value)
void add_this_to_method_type(const irep_idt &compound_identifier, typet &method_type, const typet &method_qualifier)
typet merge_type(const typet &declaration_type) const
Symbol table entry.This is a symbol in the symbol table, stored in an object of type symbol_tablet...
static mstreamt & eom(mstreamt &m)
void check_member_initializers(const irept &bases, const struct_typet::componentst &components, const irept &initializers)
Check a constructor initialization-list.
bool get_bool(const irep_namet &name) const
irep_idt get_pretty_name()
void set_base_name(const irep_idt &name)
symbol_tablet & symbol_table
void add_method_body(symbolt *_method_symbol)
const irep_idt & id() const
const source_locationt & source_location() const
const irep_idt & get_base_name() const
void set_inlined(bool value)
source_locationt & location()
source_locationt source_location
symbolt & convert_new_symbol(const cpp_storage_spect &storage_spec, const cpp_member_spect &member_spec, cpp_declaratort &declarator)
bool is_reference(const typet &type)
TO_BE_DOCUMENTED.
const irep_idt & get(const irep_namet &name) const
void enforce_rules(const symbolt &symbol)
void convert_initializer(symbolt &symbol)
Initialize an object with a value.
std::string cpp_type2name(const typet &type)
irept & method_qualifier()
Base class for tree-like data structures with sharing.
C++ Language Type Checking.
exprt resolve(const cpp_namet &cpp_name, const cpp_typecheck_resolvet::wantt want, const cpp_typecheck_fargst &fargs, bool fail_with_exception=true)
bool move(symbolt &symbol, symbolt *&new_symbol)
Move a symbol into the symbol table.
cpp_declarator_convertert(class cpp_typecheckt &_cpp_typecheck)
const struct_typet & to_struct_type(const typet &type)
Cast a generic typet to a struct_typet.
bool is_global_scope() const
const irep_idt & display_name() const
irep_idt function_identifier(const typet &type)
for function overloading
bool is_template_parameter
typet type
Type of symbol.
source_locationt location
Source code location of definition of symbol.
void set_identifier(const irep_idt &identifier)
bool is_number(const typet &type)
irep_idt final_identifier
Base class for all expressions.
void operator_overloading_rules(const symbolt &symbol)
const parameterst & parameters() const
irep_idt base_name
Base (non-scoped) name.
cpp_scopet & current_scope()
irept & member_initializers()
symbolt & convert(const typet &type, const cpp_storage_spect &storage_spec, const cpp_member_spect &member_spec, cpp_declaratort &declarator)
const source_locationt & source_location() const
virtual std::string to_string(const typet &type)
const code_typet & to_code_type(const typet &type)
Cast a generic typet to a code_typet.
dynamic_initializationst dynamic_initializations
source_locationt & add_source_location()
signedbv_typet signed_int_type()
const typet & subtype() const
const irep_idt & get_identifier() const
std::set< cpp_idt * > id_sett
const irept & find(const irep_namet &name) const
const typet & return_type() const
void combine_types(const source_locationt &source_location, const typet &decl_type, symbolt &symbol)
void set(const irep_namet &name, const irep_idt &value)
void lookup_identifier(const irep_idt &identifier, cpp_idt::id_classt id_class, id_sett &id_set)
void handle_initializer(symbolt &symbol, cpp_declaratort &declarator)
cpp_scopet & resolve_scope(const cpp_namet &cpp_name, irep_idt &base_name, cpp_template_args_non_tct &template_args)
#define forall_irep(it, irep)