aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEugen Wissner <belka@caraus.de>2026-09-19 22:08:45 +0200
committerEugen Wissner <belka@caraus.de>2026-09-19 22:08:45 +0200
commitb3cf1d087283bd85e0d9906dfdc320bd9eb4021a (patch)
tree60bfca5a8122dad2e60cfecd91ed05744de7d905
parentea8d4c933fc0a449920f453d0ddff1ba9e8a99a6 (diff)
downloadelna-b3cf1d087283bd85e0d9906dfdc320bd9eb4021a.tar.gz
Fix realiasing builtin types during codegen
-rw-r--r--gcc/gcc/elna-builtins.cc10
-rw-r--r--gcc/gcc/elna-generic.cc6
-rw-r--r--gcc/gcc/elna-tree.cc4
-rw-r--r--testsuite/compilable/aliased_type_constant.elna12
4 files changed, 22 insertions, 10 deletions
diff --git a/gcc/gcc/elna-builtins.cc b/gcc/gcc/elna-builtins.cc
index 365ddb9..0da991a 100644
--- a/gcc/gcc/elna-builtins.cc
+++ b/gcc/gcc/elna-builtins.cc
@@ -307,6 +307,7 @@ namespace elna::gcc
TREE_PUBLIC(looked_up) = 1;
TYPE_NAME(placeholder) = DECL_NAME(looked_up);
+ TYPE_STUB_DECL(placeholder) = looked_up;
symbols->enter(symbol_name, looked_up);
tree type_tree = get_inner_alias(reference->referent, symbols, placeholder);
@@ -318,15 +319,14 @@ namespace elna::gcc
{
TREE_TYPE(looked_up) = type_tree;
}
- if (is_unique_type(type_tree))
+ // Only a record or an enumeration built for this declaration takes
+ // its name. Every other referent is a shared node, and an alias
+ // refers to it without renaming it.
+ if (is_unique_type(type_tree) && TYPE_NAME(type_tree) == NULL_TREE)
{
TYPE_NAME(type_tree) = DECL_NAME(looked_up);
TYPE_STUB_DECL(type_tree) = looked_up;
}
- else
- {
- TYPE_NAME(type_tree) = looked_up;
- }
}
return looked_up;
}
diff --git a/gcc/gcc/elna-generic.cc b/gcc/gcc/elna-generic.cc
index 1853e60..46c8edc 100644
--- a/gcc/gcc/elna-generic.cc
+++ b/gcc/gcc/elna-generic.cc
@@ -717,11 +717,11 @@ namespace elna::gcc
{
expression->lhs().accept(this);
tree left = this->current_expression;
- tree left_type = get_qualified_type(TREE_TYPE(left), TYPE_UNQUALIFIED);
+ tree left_type = TYPE_MAIN_VARIANT(TREE_TYPE(left));
expression->rhs().accept(this);
tree right = this->current_expression;
- tree right_type = get_qualified_type(TREE_TYPE(right), TYPE_UNQUALIFIED);
+ tree right_type = TYPE_MAIN_VARIANT(TREE_TYPE(right));
const location_t expression_location = get_location(&expression->position());
@@ -1214,7 +1214,7 @@ namespace elna::gcc
{
statement->condition().accept(this);
tree condition_expression = this->current_expression;
- tree unqualified_condition = get_qualified_type(TREE_TYPE(condition_expression), TYPE_UNQUALIFIED);
+ tree unqualified_condition = TYPE_MAIN_VARIANT(TREE_TYPE(condition_expression));
if (INTEGRAL_TYPE_P(unqualified_condition))
{
diff --git a/gcc/gcc/elna-tree.cc b/gcc/gcc/elna-tree.cc
index 7e9197f..690cf41 100644
--- a/gcc/gcc/elna-tree.cc
+++ b/gcc/gcc/elna-tree.cc
@@ -108,8 +108,8 @@ namespace elna::gcc
tree do_pointer_arithmetic(boot::binary_operator binary_operator,
tree left, tree right, location_t operation_location)
{
- tree left_type = get_qualified_type(TREE_TYPE(left), TYPE_UNQUALIFIED);
- tree right_type = get_qualified_type(TREE_TYPE(right), TYPE_UNQUALIFIED);
+ tree left_type = TYPE_MAIN_VARIANT(TREE_TYPE(left));
+ tree right_type = TYPE_MAIN_VARIANT(TREE_TYPE(right));
if (binary_operator == boot::binary_operator::sum)
{
tree pointer{ NULL_TREE };
diff --git a/testsuite/compilable/aliased_type_constant.elna b/testsuite/compilable/aliased_type_constant.elna
new file mode 100644
index 0000000..16a52c2
--- /dev/null
+++ b/testsuite/compilable/aliased_type_constant.elna
@@ -0,0 +1,12 @@
+type
+ Handle = Int
+
+var
+ limit: const Int := 1
+
+proc check()
+begin
+ assert(limit = 1)
+return
+
+end.