End while and if statements with the end token

This commit is contained in:
2025-01-17 10:11:40 +01:00
parent ef667e3ace
commit 4b303024d9
7 changed files with 183 additions and 85 deletions

View File

@ -538,7 +538,7 @@ namespace gcc
tree record_type_node = make_node(RECORD_TYPE);
tree_chain record_chain;
for (auto& field : record_type->fields())
for (auto& field : record_type->fields)
{
if (field_names.find(field.first) != field_names.cend())
{
@ -564,6 +564,38 @@ namespace gcc
return record_type_node;
}
else if (source::union_type_expression *union_type = type.is_union())
{
std::set<std::string> field_names;
tree union_type_node = make_node(UNION_TYPE);
tree_chain union_chain;
for (auto& field : union_type->fields)
{
if (field_names.find(field.first) != field_names.cend())
{
error_at(get_location(&field.second->position()), "repeated field name");
return error_mark_node;
}
field_names.insert(field.first);
tree field_type = build_type(*field.second);
if (field_type == NULL_TREE || field_type == error_mark_node)
{
return field_type;
}
tree field_declaration = build_decl(get_location(&field.second->position()),
FIELD_DECL, get_identifier(field.first.c_str()), field_type);
TREE_ADDRESSABLE(field_declaration) = 1;
DECL_CONTEXT(field_declaration) = union_type_node;
union_chain.append(field_declaration);
}
TYPE_FIELDS(union_type_node) = union_chain.head();
layout_type(union_type_node);
return union_type_node;
}
return NULL_TREE;
}