mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-07 16:18:52 +00:00
Fix IR print bug for empty structs;
This commit is contained in:
+2
-1
@@ -1733,7 +1733,8 @@ void check_collect_entities(Checker *c, Array<AstNode *> nodes, bool is_file_sco
|
|||||||
DeclInfo *d = make_declaration_info(c->allocator, c->context.scope, c->context.decl);
|
DeclInfo *d = make_declaration_info(c->allocator, c->context.scope, c->context.decl);
|
||||||
Entity *e = nullptr;
|
Entity *e = nullptr;
|
||||||
|
|
||||||
if (is_ast_node_type(init)) {
|
if (is_ast_node_type(init) ||
|
||||||
|
(vd->type != nullptr && vd->type->kind == AstNode_TypeType)) {
|
||||||
e = make_entity_type_name(c->allocator, d->scope, token, nullptr);
|
e = make_entity_type_name(c->allocator, d->scope, token, nullptr);
|
||||||
if (vd->type != nullptr) {
|
if (vd->type != nullptr) {
|
||||||
error(name, "A type declaration cannot have an type parameter");
|
error(name, "A type declaration cannot have an type parameter");
|
||||||
|
|||||||
+2
-3
@@ -6370,9 +6370,8 @@ void ir_build_stmt_internal(irProcedure *proc, AstNode *node) {
|
|||||||
case_ast_node(ds, DeferStmt, node);
|
case_ast_node(ds, DeferStmt, node);
|
||||||
ir_emit_comment(proc, str_lit("DeferStmt"));
|
ir_emit_comment(proc, str_lit("DeferStmt"));
|
||||||
isize scope_index = proc->scope_index;
|
isize scope_index = proc->scope_index;
|
||||||
if (ds->stmt->kind == AstNode_BlockStmt) {
|
// TODO(bill): What was the original rationale behind this line?
|
||||||
scope_index--;
|
// if (ds->stmt->kind == AstNode_BlockStmt) scope_index--;
|
||||||
}
|
|
||||||
ir_add_defer_node(proc, scope_index, ds->stmt);
|
ir_add_defer_node(proc, scope_index, ds->stmt);
|
||||||
case_end;
|
case_end;
|
||||||
|
|
||||||
|
|||||||
+6
-2
@@ -246,10 +246,14 @@ void ir_print_type(irFileBuffer *f, irModule *m, Type *t) {
|
|||||||
case Basic_any: ir_fprintf(f, "%%..any"); return;
|
case Basic_any: ir_fprintf(f, "%%..any"); return;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Type_Pointer:
|
case Type_Pointer: {
|
||||||
|
if (!is_type_named(t->Pointer.elem) && is_type_empty_struct(t->Pointer.elem)) {
|
||||||
|
ir_print_type(f, m, t_rawptr);
|
||||||
|
} else {
|
||||||
ir_print_type(f, m, t->Pointer.elem);
|
ir_print_type(f, m, t->Pointer.elem);
|
||||||
ir_fprintf(f, "*");
|
ir_fprintf(f, "*");
|
||||||
return;
|
}
|
||||||
|
} return;
|
||||||
case Type_Array:
|
case Type_Array:
|
||||||
ir_fprintf(f, "[%lld x ", t->Array.count);
|
ir_fprintf(f, "[%lld x ", t->Array.count);
|
||||||
ir_print_type(f, m, t->Array.elem);
|
ir_print_type(f, m, t->Array.elem);
|
||||||
|
|||||||
+11
-1
@@ -3250,12 +3250,22 @@ AstNode *parse_value_decl(AstFile *f, Array<AstNode *> names, CommentGroup docs)
|
|||||||
Array<AstNode *> values = {};
|
Array<AstNode *> values = {};
|
||||||
|
|
||||||
Token colon = expect_token_after(f, Token_Colon, "identifier list");
|
Token colon = expect_token_after(f, Token_Colon, "identifier list");
|
||||||
|
if (f->curr_token.kind == Token_type) {
|
||||||
|
type = ast_type_type(f, advance_token(f), nullptr);
|
||||||
|
is_mutable = false;
|
||||||
|
} else {
|
||||||
type = parse_type_attempt(f);
|
type = parse_type_attempt(f);
|
||||||
|
}
|
||||||
|
|
||||||
if (f->curr_token.kind == Token_Eq ||
|
if (f->curr_token.kind == Token_Eq ||
|
||||||
f->curr_token.kind == Token_Colon) {
|
f->curr_token.kind == Token_Colon) {
|
||||||
Token sep = advance_token(f);
|
Token sep = {};
|
||||||
|
if (!is_mutable) {
|
||||||
|
sep = expect_token_after(f, Token_Colon, "type");
|
||||||
|
} else {
|
||||||
|
sep = advance_token(f);
|
||||||
is_mutable = sep.kind != Token_Colon;
|
is_mutable = sep.kind != Token_Colon;
|
||||||
|
}
|
||||||
values = parse_rhs_expr_list(f);
|
values = parse_rhs_expr_list(f);
|
||||||
if (values.count > names.count) {
|
if (values.count > names.count) {
|
||||||
syntax_error(f->curr_token, "Too many values on the right hand side of the declaration");
|
syntax_error(f->curr_token, "Too many values on the right hand side of the declaration");
|
||||||
|
|||||||
@@ -878,6 +878,10 @@ bool is_type_empty_union(Type *t) {
|
|||||||
t = base_type(t);
|
t = base_type(t);
|
||||||
return t->kind == Type_Union && t->Union.variants.count == 0;
|
return t->kind == Type_Union && t->Union.variants.count == 0;
|
||||||
}
|
}
|
||||||
|
bool is_type_empty_struct(Type *t) {
|
||||||
|
t = base_type(t);
|
||||||
|
return t->kind == Type_Struct && !t->Struct.is_raw_union && t->Struct.fields.count == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool is_type_valid_for_keys(Type *t) {
|
bool is_type_valid_for_keys(Type *t) {
|
||||||
|
|||||||
Reference in New Issue
Block a user