mirror of
https://github.com/Ed94/Odin.git
synced 2026-07-09 21:11:36 -07: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);
|
||||
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);
|
||||
if (vd->type != nullptr) {
|
||||
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);
|
||||
ir_emit_comment(proc, str_lit("DeferStmt"));
|
||||
isize scope_index = proc->scope_index;
|
||||
if (ds->stmt->kind == AstNode_BlockStmt) {
|
||||
scope_index--;
|
||||
}
|
||||
// TODO(bill): What was the original rationale behind this line?
|
||||
// if (ds->stmt->kind == AstNode_BlockStmt) scope_index--;
|
||||
ir_add_defer_node(proc, scope_index, ds->stmt);
|
||||
case_end;
|
||||
|
||||
|
||||
+8
-4
@@ -246,10 +246,14 @@ void ir_print_type(irFileBuffer *f, irModule *m, Type *t) {
|
||||
case Basic_any: ir_fprintf(f, "%%..any"); return;
|
||||
}
|
||||
break;
|
||||
case Type_Pointer:
|
||||
ir_print_type(f, m, t->Pointer.elem);
|
||||
ir_fprintf(f, "*");
|
||||
return;
|
||||
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_fprintf(f, "*");
|
||||
}
|
||||
} return;
|
||||
case Type_Array:
|
||||
ir_fprintf(f, "[%lld x ", t->Array.count);
|
||||
ir_print_type(f, m, t->Array.elem);
|
||||
|
||||
+13
-3
@@ -3250,12 +3250,22 @@ AstNode *parse_value_decl(AstFile *f, Array<AstNode *> names, CommentGroup docs)
|
||||
Array<AstNode *> values = {};
|
||||
|
||||
Token colon = expect_token_after(f, Token_Colon, "identifier list");
|
||||
type = parse_type_attempt(f);
|
||||
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);
|
||||
}
|
||||
|
||||
if (f->curr_token.kind == Token_Eq ||
|
||||
f->curr_token.kind == Token_Colon) {
|
||||
Token sep = advance_token(f);
|
||||
is_mutable = sep.kind != Token_Colon;
|
||||
Token sep = {};
|
||||
if (!is_mutable) {
|
||||
sep = expect_token_after(f, Token_Colon, "type");
|
||||
} else {
|
||||
sep = advance_token(f);
|
||||
is_mutable = sep.kind != Token_Colon;
|
||||
}
|
||||
values = parse_rhs_expr_list(f);
|
||||
if (values.count > names.count) {
|
||||
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);
|
||||
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) {
|
||||
|
||||
Reference in New Issue
Block a user