Go to the documentation of this file.
27 is_template_parameter(false),
29 linkage_spec(_cpp_typecheck.current_linkage_spec),
36 const typet &declaration_type,
43 if(declaration_type.
id()==
"cpp-cast-operator")
53 assert(declarator.
id()==ID_cpp_declarator);
105 typet &method_qualifier=
145 return friend_symbol;
147 else if(!maybe_symbol)
152 <<
"member '" <<
base_name <<
"' not found in scope '"
175 if(symbol_expr.
id() != ID_type)
187 if(declarator.
find(ID_member_initializers).
is_nil())
188 declarator.
set(ID_member_initializers, ID_member_initializers);
220 const auto maybe_symbol=
229 if(declarator.
get_bool(ID_C_template_case))
238 if(symbol.
type.
id()==
"cpp-template-type")
257 const typet &decl_type,
260 if(symbol.
type.
id()==decl_type.
id() &&
261 decl_type.
id()==ID_code)
274 for(std::size_t i=0; i<decl_code_type.
parameters().size(); i++)
282 if(decl_parameter.
type()!=symbol_parameter.
type())
285 if(i != 0 || !symbol_code_type.
get_bool(ID_C_is_virtual))
289 <<
"symbol '" << symbol.
display_name() <<
"': parameter "
290 << (i + 1) <<
" type mismatch\n"
314 else if(symbol.
type==decl_type)
317 symbol.
type.
id() == ID_array &&
322 symbol.
type = decl_type;
328 <<
"' already declared with different type:\n"
351 if(symbol.
type.
id() == ID_code)
417 symbol_tablet::symbolst::const_iterator
421 c_it->second.type.id()==ID_code &&
476 parameter.set_identifier(
irep_idt());
484 symbol.
value.
id() == ID_constant);
514 <<
"cpp_typecheckt::convert_declarator: symbol_table.move() failed"
524 for(
const auto &id_ptr : id_set)
530 if(!
id.is_class() && !
id.is_enum())
577 for(
auto it = parameters.begin(); it != parameters.end(); ++it)
579 const typet ¶meter_type = ((
exprt &)*it).type();
581 if(it!=parameters.begin())
603 if(symbol.
name==ID_main)
605 if(symbol.
type.
id()!=ID_code)
612 const typet &return_type=
620 throw "main must return int";
#define UNREACHABLE
This should be used to mark dead code.
const componentst & components() const
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
void operator_overloading_rules(const symbolt &symbol)
bool is_number(const typet &type)
Returns true if the type is a rational, real, integer, natural, complex, unsignedbv,...
const struct_typet & to_struct_type(const typet &type)
Cast a typet to a struct_typet.
id_sett lookup(const irep_idt &base_name_to_lookup, lookup_kindt kind)
const irep_idt & display_name() const
Return language specific display name if present.
The type of an expression, extends irept.
void main_function_rules(const symbolt &symbol)
const irept & find(const irep_idt &name) const
void check_fixed_size_array(typet &type)
check that an array has fixed size
typet type
Type of symbol.
void set_identifier(const irep_idt &identifier)
const typet & subtype() const
symbolt & convert(const typet &type, const cpp_storage_spect &storage_spec, const cpp_member_spect &member_spec, cpp_declaratort &declarator)
Base class for all expressions.
irep_idt base_name
Base (non-scoped) name.
bool get_is_parameter() const
void get_final_identifier()
id_sett lookup_identifier(const irep_idt &id, cpp_idt::id_classt identifier_class)
cpp_idt & put_into_scope(const symbolt &symbol, cpp_scopet &scope, bool is_friend=false)
bool cpp_typecheck(cpp_parse_treet &cpp_parse_tree, symbol_tablet &symbol_table, const std::string &module, message_handlert &message_handler)
const irep_idt & get(const irep_idt &name) const
irep_idt pretty_name
Language-specific display name.
const exprt & size() const
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 typecheck_type(typet &) override
const code_typet & to_code_type(const typet &type)
Cast a typet to a code_typet.
bool is_code_type(const typet &type) const
irep_idt mode
Language mode.
const irep_idt & get_base_name() const
signedbv_typet signed_int_type()
void add_method_body(symbolt *_method_symbol)
void convert_initializer(symbolt &symbol)
Initialize an object with a value.
const std::string & id2string(const irep_idt &d)
cpp_scopet & current_scope()
source_locationt source_location
void set(const irep_idt &name, const irep_idt &value)
void check_member_initializers(const struct_typet::basest &bases, const struct_typet::componentst &components, const irept &initializers)
Check a constructor initialization-list.
void set_inlined(bool value)
const basest & bases() const
Get the collection of base classes/structs.
symbol_tablet & symbol_table
irep_idt get_pretty_name()
bool is_template_parameter
const irep_idt & id() const
symbolt & convert_new_symbol(const cpp_storage_spect &storage_spec, const cpp_member_spect &member_spec, cpp_declaratort &declarator)
bool is_global_scope() const
irep_idt function_identifier(const typet &type)
for function overloading
const parameterst & parameters() const
irept & member_initializers()
void set_base_name(const irep_idt &name)
virtual bool move(symbolt &symbol, symbolt *&new_symbol) override
Move a symbol into the symbol table.
void full_member_initialization(const struct_union_typet &struct_union_type, irept &initializers)
Build the full initialization list of the constructor.
void handle_initializer(symbolt &symbol, cpp_declaratort &declarator)
virtual symbolt * get_writeable(const irep_idt &name) override
Find a symbol in the symbol table for read-write access.
exprt value
Initial value of symbol.
bool is_reference(const typet &type)
Returns true if the type is a reference.
void add_this_to_method_type(const symbolt &compound_symbol, code_typet &method_type, const typet &method_qualifier)
Structure type, corresponds to C style structs.
const source_locationt & source_location() const
cpp_scopet & resolve_scope(const cpp_namet &cpp_name, irep_idt &base_name, cpp_template_args_non_tct &template_args)
std::string cpp_type2name(const typet &type)
source_locationt location
Source code location of definition of symbol.
const symbolst & symbols
Read-only field, used to look up symbols given their names.
irept & method_qualifier()
static bool has_auto(const typet &type)
const array_typet & to_array_type(const typet &type)
Cast a typet to an array_typet.
bool is_thread_local() const
void enforce_rules(const symbolt &symbol)
const typet & return_type() const
void combine_types(const source_locationt &source_location, const typet &decl_type, symbolt &symbol)
irep_idt final_identifier
std::string to_string(const typet &) override
cpp_declarator_convertert(class cpp_typecheckt &_cpp_typecheck)
source_locationt & add_source_location()
template_typet & to_template_type(typet &type)
irep_idt module
Name of module the symbol belongs to.
exprt resolve(const cpp_namet &cpp_name, const cpp_typecheck_resolvet::wantt want, const cpp_typecheck_fargst &fargs, bool fail_with_exception=true)
const source_locationt & source_location() const
dynamic_initializationst dynamic_initializations
irep_idt name
The unique identifier.
bool get_bool(const irep_idt &name) const
class cpp_typecheckt & cpp_typecheck
void move_member_initializers(irept &initializers, const code_typet &type, exprt &value)
const typet & element_type() const
The type of the elements of the array.
typet merge_type(const typet &declaration_type) const