Make array ptr and length properties constant
This commit is contained in:
@ -1046,13 +1046,14 @@ namespace elna::gcc
|
||||
|
||||
if (is_array_type(aggregate_type) && expression->field() == "length")
|
||||
{
|
||||
this->current_expression = fold_convert(elna_word_type_node,
|
||||
this->current_expression = fold_convert(build_qualified_type(elna_word_type_node, TYPE_QUAL_CONST),
|
||||
TYPE_MAX_VALUE(TYPE_DOMAIN(aggregate_type)));
|
||||
}
|
||||
else if (is_array_type(aggregate_type) && expression->field() == "ptr")
|
||||
{
|
||||
tree ptr_type = build_pointer_type_for_mode(TREE_TYPE(aggregate_type), VOIDmode, true);
|
||||
this->current_expression = build1(ADDR_EXPR, ptr_type, this->current_expression);
|
||||
this->current_expression = build1(ADDR_EXPR,
|
||||
build_qualified_type(ptr_type, TYPE_QUAL_CONST), this->current_expression);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1099,25 +1100,27 @@ namespace elna::gcc
|
||||
|
||||
if (TREE_CODE(lvalue) == CONST_DECL)
|
||||
{
|
||||
error_at(statement_location, "cannot modify constant '%s'",
|
||||
error_at(statement_location, "Cannot modify constant '%s'",
|
||||
statement->lvalue().is_variable()->name.c_str());
|
||||
this->current_expression = error_mark_node;
|
||||
}
|
||||
else if (TYPE_READONLY(TREE_TYPE(lvalue)))
|
||||
{
|
||||
error_at(statement_location, "Cannot modify a constant expression of type '%s'",
|
||||
print_type(TREE_TYPE(lvalue)).c_str());
|
||||
}
|
||||
else if (is_assignable_from(TREE_TYPE(lvalue), rvalue))
|
||||
{
|
||||
tree assignment = build2_loc(statement_location, MODIFY_EXPR, void_type_node, lvalue, rvalue);
|
||||
|
||||
append_statement(assignment);
|
||||
this->current_expression = NULL_TREE;
|
||||
}
|
||||
else
|
||||
{
|
||||
error_at(statement_location,
|
||||
"cannot assign value of type '%s' to variable of type '%s'",
|
||||
error_at(statement_location, "Cannot assign value of type '%s' to variable of type '%s'",
|
||||
print_type(TREE_TYPE(rvalue)).c_str(),
|
||||
print_type(TREE_TYPE(lvalue)).c_str());
|
||||
this->current_expression = error_mark_node;
|
||||
}
|
||||
this->current_expression = NULL_TREE;
|
||||
}
|
||||
|
||||
void generic_visitor::visit(boot::if_statement *statement)
|
||||
|
Reference in New Issue
Block a user