Allow extern variables

This commit is contained in:
2025-08-20 21:47:50 +02:00
parent 0c2a396320
commit 809e41bcc3
8 changed files with 45 additions and 12 deletions

View File

@@ -108,7 +108,7 @@ namespace elna::gcc
if (!is_assignable_from(unqualified_field, this->current_expression))
{
error_at(argument_location,
"cannot assign value of type '%s' to variable of type '%s'",
"Cannot assign value of type '%s' to variable of type '%s'",
print_type(TREE_TYPE(this->current_expression)).c_str(),
print_type(TREE_TYPE(record_fields)).c_str());
this->current_expression = error_mark_node;
@@ -756,6 +756,7 @@ namespace elna::gcc
get_identifier(variable_identifier.identifier.c_str()), this->current_expression);
bool result = this->symbols->enter(variable_identifier.identifier, declaration_tree);
// Set initializer if given.
if (declaration->body != nullptr)
{
declaration->body->accept(this);
@@ -774,6 +775,7 @@ namespace elna::gcc
{
DECL_INITIAL(declaration_tree) = elna_pointer_nil_node;
}
DECL_EXTERNAL(declaration_tree) = declaration->is_extern;
TREE_PUBLIC(declaration_tree) = variable_identifier.exported;
this->current_expression = NULL_TREE;
if (!result)