26 is_template_parameter(false),
28 linkage_spec(_cpp_typecheck.current_linkage_spec),
35 const typet &declaration_type,
42 if(declaration_type.
id()==
"cpp-cast-operator")
52 assert(declarator.
id()==ID_cpp_declarator);
87 typet &method_qualifier=
121 <<
"' not found in scope `" 146 symbol_expr.
id() != ID_type ||
147 symbol_expr.
type().
id() != ID_symbol_type)
159 if(declarator.
find(ID_member_initializers).
is_nil())
160 declarator.
set(ID_member_initializers, ID_member_initializers);
192 const auto maybe_symbol=
201 if(declarator.
get_bool(ID_C_template_case))
210 if(symbol.
type.
id()==
"cpp-template-type")
229 const typet &decl_type,
232 if(symbol.
type.
id()==decl_type.
id() &&
233 decl_type.
id()==ID_code)
246 for(std::size_t i=0; i<decl_code_type.
parameters().size(); i++)
254 if(decl_parameter.
type()!=symbol_parameter.
type())
257 if(i != 0 || !symbol_code_type.
get_bool(ID_C_is_virtual))
261 <<
"': parameter " << (i+1)
262 <<
" type mismatch\n" 265 symbol_parameter.
type())
268 decl_parameter.
type())
287 else if(symbol.
type==decl_type)
289 else if(symbol.
type.
id()==ID_array &&
291 decl_type.
id()==ID_array &&
294 symbol.
type = decl_type;
300 <<
"' already declared with different type:\n" 325 if(symbol.
type.
id() == ID_code)
355 <<
"' has already been defined";
359 <<
"' already has an initializer";
389 symbol_tablet::symbolst::const_iterator
393 c_it->second.type.id()==ID_code &&
438 symbol.
type.
set(ID_C_inlined,
true);
455 symbol.
value.
id() == ID_constant);
492 <<
"cpp_typecheckt::convert_declarator: symbol_table.move() failed" 502 for(
const auto &id_ptr : id_set)
508 if(!
id.is_class() && !
id.is_enum())
512 <<
"' already in scope" 558 const typet ¶meter_type=((
exprt &)*it).type();
560 if(it!=parameters.begin())
582 if(symbol.
name==ID_main)
584 if(symbol.
type.
id()!=ID_code)
591 const typet &return_type=
599 throw "main must return int";
C++ Language Type Checking.
The type of an expression, extends irept.
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()
const std::string & id2string(const irep_idt &d)
class cpp_typecheckt & cpp_typecheck
static bool has_auto(const typet &type)
std::vector< irept > subt
irep_idt mode
Language mode.
id_sett lookup_identifier(const irep_idt &id, cpp_idt::id_classt identifier_class)
bool is_code_type(const typet &type) const
const code_typet & to_code_type(const typet &type)
Cast a typet to a code_typet.
void full_member_initialization(const struct_union_typet &struct_union_type, irept &initializers)
Build the full initialization list of the constructor.
id_sett lookup(const irep_idt &base_name_to_lookup, lookup_kindt kind)
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.
typet & type()
Return the type of the expression.
bool cpp_typecheck(cpp_parse_treet &cpp_parse_tree, symbol_tablet &symbol_table, const std::string &module, message_handlert &message_handler)
typet merge_type(const typet &declaration_type) const
Structure type, corresponds to C style structs.
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
virtual symbolt * get_writeable(const irep_idt &name) override
Find a symbol in the symbol table for read-write access.
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)
void add_this_to_method_type(const symbolt &compound_symbol, code_typet &method_type, const typet &method_qualifier)
source_locationt & location()
const basest & bases() const
Get the collection of base classes/structs.
virtual bool move(symbolt &symbol, symbolt *&new_symbol) override
Move a symbol into the symbol table.
void check_member_initializers(const struct_typet::basest &bases, const struct_typet::componentst &components, const irept &initializers)
Check a constructor initialization-list.
source_locationt source_location
symbolt & convert_new_symbol(const cpp_storage_spect &storage_spec, const cpp_member_spect &member_spec, cpp_declaratort &declarator)
void typecheck_type(typet &) override
bool is_reference(const typet &type)
Returns true if the type is a reference.
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()
C++ Language Type Checking.
const struct_typet & to_struct_type(const typet &type)
Cast a typet to a struct_typet.
dstringt has one field, an unsigned integer no which is an index into a static table of strings...
exprt resolve(const cpp_namet &cpp_name, const cpp_typecheck_resolvet::wantt want, const cpp_typecheck_fargst &fargs, bool fail_with_exception=true)
cpp_declarator_convertert(class cpp_typecheckt &_cpp_typecheck)
bool is_global_scope() const
const irep_idt & display_name() const
Return language specific display name if present.
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)
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
#define UNREACHABLE
This should be used to mark dead code.
dynamic_initializationst dynamic_initializations
source_locationt & add_source_location()
void move_member_initializers(irept &initializers, const code_typet &type, exprt &value)
bool is_number(const typet &type)
Returns true if the type is a rational, real, integer, natural, complex, unsignedbv, signedbv, floatbv or fixedbv.
signedbv_typet signed_int_type()
const typet & subtype() const
std::string to_string(const typet &) override
const irep_idt & get_identifier() const
const irept & find(const irep_namet &name) const
const typet & return_type() const
bool lookup(const irep_idt &name, const symbolt *&symbol) const override
See documentation for namespace_baset::lookup().
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 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)