Allow comparing all pointer types to nil
This commit is contained in:
@ -94,35 +94,21 @@ namespace gcc
|
||||
|
||||
void generic_visitor::visit(boot::program *program)
|
||||
{
|
||||
for (const auto& type_definition : program->type_definitions)
|
||||
{
|
||||
type_definition->accept(this);
|
||||
}
|
||||
for (const auto constant : program->constants)
|
||||
for (boot::constant_definition *const constant : program->constants)
|
||||
{
|
||||
constant->accept(this);
|
||||
}
|
||||
for (const auto declaration : program->variables)
|
||||
for (boot::type_definition *const type : program->types)
|
||||
{
|
||||
tree declaration_type = build_type(declaration->type());
|
||||
gcc_assert(declaration_type != NULL_TREE);
|
||||
|
||||
auto declaration_location = get_location(&declaration->position());
|
||||
tree declaration_tree = build_decl(declaration_location, VAR_DECL,
|
||||
get_identifier(declaration->identifier().c_str()), declaration_type);
|
||||
auto result = this->symbol_map->enter(declaration->identifier(), boot::make_info(declaration_tree));
|
||||
|
||||
if (result)
|
||||
{
|
||||
TREE_STATIC(declaration_tree) = 1;
|
||||
varpool_node::get_create(declaration_tree);
|
||||
varpool_node::finalize_decl(declaration_tree);
|
||||
}
|
||||
else
|
||||
{
|
||||
error_at(declaration_location, "variable '%s' already declared in this scope",
|
||||
declaration->identifier().c_str());
|
||||
}
|
||||
type->accept(this);
|
||||
}
|
||||
for (boot::variable_declaration *const variable : program->variables)
|
||||
{
|
||||
variable->accept(this);
|
||||
}
|
||||
for (boot::procedure_definition *const procedure : program->procedures)
|
||||
{
|
||||
procedure->accept(this);
|
||||
}
|
||||
std::array<tree, 2> parameter_types{
|
||||
integer_type_node,
|
||||
@ -149,7 +135,7 @@ namespace gcc
|
||||
}
|
||||
DECL_ARGUMENTS(this->main_fndecl) = argument_chain.head();
|
||||
|
||||
for (const auto body_statement : program->body)
|
||||
for (boot::statement *const body_statement : program->body)
|
||||
{
|
||||
body_statement->accept(this);
|
||||
}
|
||||
@ -359,7 +345,7 @@ namespace gcc
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (left_type != right_type)
|
||||
if (left_type != right_type && !are_compatible_pointers(left, right))
|
||||
{
|
||||
error_at(expression_location,
|
||||
"invalid operands of type %s and %s for operator %s",
|
||||
@ -601,12 +587,23 @@ namespace gcc
|
||||
tree declaration_type = build_type(declaration->type());
|
||||
gcc_assert(declaration_type != NULL_TREE);
|
||||
|
||||
auto declaration_location = get_location(&declaration->position());
|
||||
location_t declaration_location = get_location(&declaration->position());
|
||||
tree declaration_tree = build_decl(declaration_location, VAR_DECL,
|
||||
get_identifier(declaration->identifier().c_str()), declaration_type);
|
||||
auto result = this->symbol_map->enter(declaration->identifier(), boot::make_info(declaration_tree));
|
||||
bool result = this->symbol_map->enter(declaration->identifier(), boot::make_info(declaration_tree));
|
||||
|
||||
if (result)
|
||||
if (!result)
|
||||
{
|
||||
error_at(declaration_location, "variable '%s' already declared in this scope",
|
||||
declaration->identifier().c_str());
|
||||
}
|
||||
else if (this->main_fndecl == NULL_TREE)
|
||||
{
|
||||
TREE_STATIC(declaration_tree) = 1;
|
||||
varpool_node::get_create(declaration_tree);
|
||||
varpool_node::finalize_decl(declaration_tree);
|
||||
}
|
||||
else
|
||||
{
|
||||
DECL_CONTEXT(declaration_tree) = this->main_fndecl;
|
||||
variable_chain.append(declaration_tree);
|
||||
@ -615,12 +612,6 @@ namespace gcc
|
||||
void_type_node, declaration_tree);
|
||||
append_to_statement_list(declaration_statement, &this->current_statements);
|
||||
}
|
||||
else
|
||||
{
|
||||
error_at(declaration_location,
|
||||
"variable '%s' already declared in this scope",
|
||||
declaration->identifier().c_str());
|
||||
}
|
||||
}
|
||||
|
||||
void generic_visitor::visit(boot::variable_expression *expression)
|
||||
|
Reference in New Issue
Block a user