From b3cf1d087283bd85e0d9906dfdc320bd9eb4021a Mon Sep 17 00:00:00 2001 From: Eugen Wissner Date: Sat, 19 Sep 2026 22:08:45 +0200 Subject: Fix realiasing builtin types during codegen --- gcc/gcc/elna-builtins.cc | 10 +++++----- gcc/gcc/elna-generic.cc | 6 +++--- gcc/gcc/elna-tree.cc | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) (limited to 'gcc') 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 }; -- cgit v1.2.3