Check only a pointer can be dereferenced
This commit is contained in:
@ -1071,9 +1071,20 @@ namespace elna::gcc
|
||||
void generic_visitor::visit(boot::dereference_expression *expression)
|
||||
{
|
||||
expression->base().accept(this);
|
||||
location_t expression_location = get_location(&expression->position());
|
||||
tree expression_type = TREE_TYPE(this->current_expression);
|
||||
|
||||
this->current_expression = build1_loc(get_location(&expression->position()), INDIRECT_REF,
|
||||
TREE_TYPE(TREE_TYPE(this->current_expression)), this->current_expression);
|
||||
if (is_pointer_type(expression_type))
|
||||
{
|
||||
this->current_expression = build1_loc(expression_location, INDIRECT_REF,
|
||||
TREE_TYPE(expression_type), this->current_expression);
|
||||
}
|
||||
else
|
||||
{
|
||||
error_at(expression_location, "Type '%s' cannot be dereferenced, it is not a pointer",
|
||||
print_type(expression_type).c_str());
|
||||
this->current_expression = error_mark_node;
|
||||
}
|
||||
}
|
||||
|
||||
void generic_visitor::visit(boot::assign_statement *statement)
|
||||
|
Reference in New Issue
Block a user