Refactor: Remove dead code

This commit is contained in:
Ginger Bill
2016-10-02 21:45:24 +01:00
parent 264fc1e1f3
commit f6589d9814
8 changed files with 111 additions and 161 deletions
+8 -7
View File
@@ -4,12 +4,13 @@
#import "mem.odin" #import "mem.odin"
#import "game.odin" #import "game.odin"
Vec3 :: struct {
x, y, z: f32
}
main :: proc() { main :: proc() {
v0 := V Vector3 :: struct {
v1 := V x, y, z: f32
v2 := V }
Entity :: struct {
guid: u64
position: Vector3
}
} }
+3 -1
View File
@@ -80,7 +80,9 @@ print_nl_to_buffer :: proc(buf: ^[]byte) { print_rune_to_buffer(buf, #rune "\
print_int_to_buffer :: proc(buf: ^[]byte, i: int) { print_int_to_buffer :: proc(buf: ^[]byte, i: int) {
print_int_base_to_buffer(buf, i, 10); print_int_base_to_buffer(buf, i, 10);
} }
__NUM_TO_CHAR_TABLE :: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz@$"
__NUM_TO_CHAR_TABLE := "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz@$"
print_int_base_to_buffer :: proc(buffer: ^[]byte, i, base: int) { print_int_base_to_buffer :: proc(buffer: ^[]byte, i, base: int) {
buf: [65]byte buf: [65]byte
+6 -27
View File
@@ -267,6 +267,12 @@ CycleChecker *cycle_checker_add(CycleChecker *cc, Entity *e) {
return cc; return cc;
} }
void cycle_checker_destroy(CycleChecker *cc) {
if (cc != NULL && cc->path != NULL) {
gb_array_free(cc->path);
}
}
Scope *make_scope(Scope *parent, gbAllocator allocator) { Scope *make_scope(Scope *parent, gbAllocator allocator) {
@@ -871,33 +877,6 @@ Map<Entity *> generate_minimum_dependency_map(CheckerInfo *info, Entity *start)
#include "expr.cpp" #include "expr.cpp"
#include "stmt.cpp" #include "stmt.cpp"
struct CycleCheck {
gbArray(Entity *) path; // HACK(bill): Memory Leak
};
void cycle_check_add(CycleCheck *cc, Entity *entity) {
if (cc == NULL)
return;
if (cc->path == NULL) {
gb_array_init(cc->path, gb_heap_allocator());
}
GB_ASSERT(entity->kind == Entity_TypeName);
gb_array_append(cc->path, entity);
}
void check_type_name_cycles(Checker *c, CycleCheck *cc, Entity *e) {
GB_ASSERT(e->kind == Entity_TypeName);
Type *t = e->type;
// if (t->kind == Type_Named) {
// if (t->Named.type_name == e) {
// gb_printf("Illegal cycle %.*s!!!\n", LIT(e->token.string));
// GB_PANIC("!!!");
// }
// }
}
void init_runtime_types(Checker *c) { void init_runtime_types(Checker *c) {
if (t_type_info == NULL) { if (t_type_info == NULL) {
Entity *e = current_scope_lookup_entity(c->global_scope, make_string("Type_Info")); Entity *e = current_scope_lookup_entity(c->global_scope, make_string("Type_Info"));
+55 -61
View File
@@ -65,7 +65,6 @@ b32 check_is_assignable_to(Checker *c, Operand *operand, Type *type, b32 is_argu
Type *src = base_type(s); Type *src = base_type(s);
Type *dst = base_type(type); Type *dst = base_type(type);
if (is_type_untyped(src)) { if (is_type_untyped(src)) {
switch (dst->kind) { switch (dst->kind) {
case Type_Basic: case Type_Basic:
@@ -86,11 +85,13 @@ b32 check_is_assignable_to(Checker *c, Operand *operand, Type *type, b32 is_argu
return true; return true;
} }
if (is_type_pointer(dst) && is_type_rawptr(src)) if (is_type_pointer(dst) && is_type_rawptr(src)) {
return true; return true;
}
if (is_type_rawptr(dst) && is_type_pointer(src)) if (is_type_rawptr(dst) && is_type_pointer(src)) {
return true; return true;
}
if (dst->kind == Type_Array && src->kind == Type_Array) { if (dst->kind == Type_Array && src->kind == Type_Array) {
if (are_types_identical(dst->Array.elem, src->Array.elem)) { if (are_types_identical(dst->Array.elem, src->Array.elem)) {
@@ -513,7 +514,6 @@ void check_struct_type(Checker *c, Type *struct_type, AstNode *node, CycleChecke
struct_type->Record.fields = reordered_fields; struct_type->Record.fields = reordered_fields;
} }
} }
void check_union_type(Checker *c, Type *union_type, AstNode *node, CycleChecker *cycle_checker) { void check_union_type(Checker *c, Type *union_type, AstNode *node, CycleChecker *cycle_checker) {
@@ -848,9 +848,7 @@ void check_identifier(Checker *c, Operand *o, AstNode *n, Type *named_type, Cycl
// if (cycle_checker == NULL) { // if (cycle_checker == NULL) {
// cycle_checker = &local_cycle_checker; // cycle_checker = &local_cycle_checker;
// } // }
// defer (if (local_cycle_checker.path != NULL) { // defer (cycle_checker_destroy(&local_cycle_checker));
// gb_array_free(local_cycle_checker.path);
// });
check_entity_decl(c, e, NULL, named_type, cycle_checker); check_entity_decl(c, e, NULL, named_type, cycle_checker);
@@ -939,8 +937,9 @@ i64 check_array_count(Checker *c, AstNode *e) {
if (is_type_untyped(o.type) || is_type_integer(o.type)) { if (is_type_untyped(o.type) || is_type_integer(o.type)) {
if (o.value.kind == ExactValue_Integer) { if (o.value.kind == ExactValue_Integer) {
i64 count = o.value.value_integer; i64 count = o.value.value_integer;
if (count >= 0) if (count >= 0) {
return count; return count;
}
error(ast_node_token(e), "Invalid array count"); error(ast_node_token(e), "Invalid array count");
return 0; return 0;
} }
@@ -966,8 +965,6 @@ Type *check_type(Checker *c, AstNode *e, Type *named_type, CycleChecker *cycle_c
break; break;
case Addressing_Type: { case Addressing_Type: {
type = o.type; type = o.type;
type->flags |= e->type_flags;
set_base_type(named_type, type);
goto end; goto end;
} break; } break;
case Addressing_NoValue: case Addressing_NoValue:
@@ -991,9 +988,7 @@ Type *check_type(Checker *c, AstNode *e, Type *named_type, CycleChecker *cycle_c
case Addressing_Type: case Addressing_Type:
GB_ASSERT(o.type != NULL); GB_ASSERT(o.type != NULL);
type = o.type; type = o.type;
type->flags |= e->type_flags; goto end;
set_base_type(named_type, type);
return type;
case Addressing_NoValue: case Addressing_NoValue:
err_str = expr_to_string(e); err_str = expr_to_string(e);
error(ast_node_token(e), "`%s` used as a type", err_str); error(ast_node_token(e), "`%s` used as a type", err_str);
@@ -1007,19 +1002,29 @@ Type *check_type(Checker *c, AstNode *e, Type *named_type, CycleChecker *cycle_c
case_ast_node(pe, ParenExpr, e); case_ast_node(pe, ParenExpr, e);
type = check_type(c, pe->expr, named_type, cycle_checker); type = check_type(c, pe->expr, named_type, cycle_checker);
type->flags |= e->type_flags; goto end;
return type; case_end;
case_ast_node(ue, UnaryExpr, e);
if (ue->op.kind == Token_Pointer) {
type = make_type_pointer(c->allocator, check_type(c, ue->expr));
goto end;
}
case_end;
case_ast_node(pt, PointerType, e);
Type *elem = check_type(c, pt->type);
type = make_type_pointer(c->allocator, elem);
goto end;
case_end; case_end;
case_ast_node(at, ArrayType, e); case_ast_node(at, ArrayType, e);
if (at->count != NULL) { if (at->count != NULL) {
type = make_type_array(c->allocator, Type *elem = check_type(c, at->elem, NULL, cycle_checker);
check_type(c, at->elem, NULL, cycle_checker), type = make_type_array(c->allocator, elem, check_array_count(c, at->count));
check_array_count(c, at->count));
set_base_type(named_type, type);
} else { } else {
type = make_type_slice(c->allocator, check_type(c, at->elem)); Type *elem = check_type(c, at->elem);
set_base_type(named_type, type); type = make_type_slice(c->allocator, elem);
} }
goto end; goto end;
case_end; case_end;
@@ -1034,7 +1039,6 @@ Type *check_type(Checker *c, AstNode *e, Type *named_type, CycleChecker *cycle_c
error(ast_node_token(vt->elem), "Vector element type must be numerical or a boolean. Got `%s`", err_str); error(ast_node_token(vt->elem), "Vector element type must be numerical or a boolean. Got `%s`", err_str);
} }
type = make_type_vector(c->allocator, elem, count); type = make_type_vector(c->allocator, elem, count);
set_base_type(named_type, type);
goto end; goto end;
case_end; case_end;
@@ -1078,12 +1082,6 @@ Type *check_type(Checker *c, AstNode *e, Type *named_type, CycleChecker *cycle_c
goto end; goto end;
case_end; case_end;
case_ast_node(pt, PointerType, e);
type = make_type_pointer(c->allocator, check_type(c, pt->type));
set_base_type(named_type, type);
goto end;
case_end;
case_ast_node(pt, ProcType, e); case_ast_node(pt, ProcType, e);
type = alloc_type(c->allocator, Type_Proc); type = alloc_type(c->allocator, Type_Proc);
set_base_type(named_type, type); set_base_type(named_type, type);
@@ -1093,34 +1091,27 @@ Type *check_type(Checker *c, AstNode *e, Type *named_type, CycleChecker *cycle_c
goto end; goto end;
case_end; case_end;
default: { case_ast_node(ce, CallExpr, e);
if (e->kind == AstNode_CallExpr) { Operand o = {};
Operand o = {}; check_expr_or_type(c, &o, e);
check_expr_or_type(c, &o, e); if (o.mode == Addressing_Type) {
if (o.mode == Addressing_Type) { type = o.type;
type = o.type; goto end;
goto end;
}
} else if (e->kind == AstNode_UnaryExpr) {
ast_node(ue, UnaryExpr, e);
if (ue->op.kind == Token_Pointer) {
type = make_type_pointer(c->allocator, check_type(c, ue->expr));
set_base_type(named_type, type);
goto end;
}
} }
case_end;
err_str = expr_to_string(e);
error(ast_node_token(e), "`%s` is not a type", err_str);
} break;
} }
err_str = expr_to_string(e);
error(ast_node_token(e), "`%s` is not a type", err_str);
type = t_invalid; type = t_invalid;
set_base_type(named_type, type);
end: end:
if (type == NULL) {
type = t_invalid;
}
set_base_type(named_type, type);
GB_ASSERT(is_type_typed(type)); GB_ASSERT(is_type_typed(type));
type->flags |= e->type_flags;
add_type_and_value(&c->info, e, Addressing_Type, type, null_value); add_type_and_value(&c->info, e, Addressing_Type, type, null_value);
return type; return type;
} }
@@ -1550,19 +1541,13 @@ b32 check_is_castable_to(Checker *c, Operand *operand, Type *y) {
return true; return true;
} }
// // untyped integers -> pointers
// if (is_type_untyped(xb) && is_type_integer(xb)) {
// if (is_type_pointer(yb))
// return true;
// }
// (u)int <-> pointer // (u)int <-> pointer
if (is_type_pointer(xb) || (is_type_int_or_uint(xb) && !is_type_untyped(xb))) { if (is_type_int_or_uint(xb) && !is_type_untyped(xb)) {
if (is_type_pointer(yb)) if (is_type_pointer(yb))
return true; return true;
} }
if (is_type_pointer(xb)) { if (is_type_pointer(xb)) {
if (is_type_pointer(yb) || (is_type_int_or_uint(yb) && !is_type_untyped(yb))) if (is_type_int_or_uint(yb) && !is_type_untyped(yb))
return true; return true;
} }
@@ -1643,7 +1628,9 @@ void check_binary_expr(Checker *c, Operand *x, AstNode *node) {
} }
} }
} else if (check_is_castable_to(c, x, type)) { } else if (check_is_castable_to(c, x, type)) {
x->mode = Addressing_Value; if (x->mode != Addressing_Constant) {
x->mode = Addressing_Value;
}
can_convert = true; can_convert = true;
} }
@@ -3963,17 +3950,24 @@ gbString write_expr_to_string(gbString str, AstNode *node) {
case_end; case_end;
case_ast_node(st, StructType, node); case_ast_node(st, StructType, node);
str = gb_string_appendc(str, "struct{"); str = gb_string_appendc(str, "struct ");
if (st->is_packed) str = gb_string_appendc(str, "#packed ");
if (st->is_ordered) str = gb_string_appendc(str, "#ordered ");
// str = write_fields_to_string(str, st->decl_list, ", "); // str = write_fields_to_string(str, st->decl_list, ", ");
str = gb_string_appendc(str, "}"); str = gb_string_appendc(str, "}");
case_end; case_end;
case_ast_node(st, RawUnionType, node); case_ast_node(st, RawUnionType, node);
str = gb_string_appendc(str, "raw_union{"); str = gb_string_appendc(str, "raw_union {");
// str = write_fields_to_string(str, st->decl_list, ", "); // str = write_fields_to_string(str, st->decl_list, ", ");
str = gb_string_appendc(str, "}"); str = gb_string_appendc(str, "}");
case_end; case_end;
case_ast_node(st, UnionType, node);
str = gb_string_appendc(str, "union {");
// str = write_fields_to_string(str, st->decl_list, ", ");
str = gb_string_appendc(str, "}");
case_end;
case_ast_node(et, EnumType, node); case_ast_node(et, EnumType, node);
str = gb_string_appendc(str, "enum "); str = gb_string_appendc(str, "enum ");
+9 -11
View File
@@ -429,14 +429,14 @@ void check_const_decl(Checker *c, Entity *e, AstNode *type_expr, AstNode *init_e
if (type_expr) { if (type_expr) {
Type *t = check_type(c, type_expr); Type *t = check_type(c, type_expr);
if (!is_type_constant_type(t)) { // if (!is_type_constant_type(t)) {
gbString str = type_to_string(t); // gbString str = type_to_string(t);
defer (gb_string_free(str)); // defer (gb_string_free(str));
error(ast_node_token(type_expr), // error(ast_node_token(type_expr),
"Invalid constant type `%s`", str); // "Invalid constant type `%s`", str);
e->type = t_invalid; // e->type = t_invalid;
return; // return;
} // }
e->type = t; e->type = t;
} }
@@ -460,9 +460,7 @@ void check_type_decl(Checker *c, Entity *e, AstNode *type_expr, Type *def, Cycle
if (cycle_checker == NULL) { if (cycle_checker == NULL) {
cycle_checker = &local_cycle_checker; cycle_checker = &local_cycle_checker;
} }
defer (if (local_cycle_checker.path != NULL) { defer (cycle_checker_destroy(&local_cycle_checker));
gb_array_free(local_cycle_checker.path);
});
Type *bt = check_type(c, type_expr, named, cycle_checker_add(cycle_checker, e)); Type *bt = check_type(c, type_expr, named, cycle_checker_add(cycle_checker, e));
named->Named.base = bt; named->Named.base = bt;
-6
View File
@@ -597,9 +597,6 @@ void ssa_print_instr(ssaFileBuffer *f, ssaModule *m, ssaValue *value) {
case ssaInstr_Store: { case ssaInstr_Store: {
Type *type = ssa_type(instr); Type *type = ssa_type(instr);
ssa_fprintf(f, "store "); ssa_fprintf(f, "store ");
if ((type->flags & TypeFlag_volatile) != 0) {
ssa_fprintf(f, "volatile ");
}
ssa_print_type(f, m, type); ssa_print_type(f, m, type);
ssa_fprintf(f, " "); ssa_fprintf(f, " ");
ssa_print_value(f, m, instr->Store.value, type); ssa_print_value(f, m, instr->Store.value, type);
@@ -613,9 +610,6 @@ void ssa_print_instr(ssaFileBuffer *f, ssaModule *m, ssaValue *value) {
case ssaInstr_Load: { case ssaInstr_Load: {
Type *type = instr->Load.type; Type *type = instr->Load.type;
ssa_fprintf(f, "%%%d = load ", value->id); ssa_fprintf(f, "%%%d = load ", value->id);
if ((type->flags & TypeFlag_volatile) != 0) {
ssa_fprintf(f, "volatile ");
}
ssa_print_type(f, m, type); ssa_print_type(f, m, type);
ssa_fprintf(f, ", "); ssa_fprintf(f, ", ");
ssa_print_type(f, m, type); ssa_print_type(f, m, type);
+4 -1
View File
@@ -176,6 +176,8 @@ int main(int argc, char **argv) {
isize base_name_len = gb_path_extension(output_name)-1 - output_name; isize base_name_len = gb_path_extension(output_name)-1 - output_name;
String output = make_string(cast(u8 *)output_name, base_name_len); String output = make_string(cast(u8 *)output_name, base_name_len);
int optimization_level = 0;
optimization_level = gb_clamp(optimization_level, 0, 3);
i32 exit_code = 0; i32 exit_code = 0;
// For more passes arguments: http://llvm.org/docs/Passes.html // For more passes arguments: http://llvm.org/docs/Passes.html
@@ -199,11 +201,12 @@ int main(int argc, char **argv) {
// For more arguments: http://llvm.org/docs/CommandGuide/llc.html // For more arguments: http://llvm.org/docs/CommandGuide/llc.html
exit_code = win32_exec_command_line_app( exit_code = win32_exec_command_line_app(
"%.*sbin/llc %.*s.bc -filetype=obj -O0 " "%.*sbin/llc %.*s.bc -filetype=obj -O%d "
"%.*s " "%.*s "
"", "",
LIT(module_dir), LIT(module_dir),
LIT(output), LIT(output),
optimization_level,
LIT(arch_data.llc_flags)); LIT(arch_data.llc_flags));
if (exit_code != 0) { if (exit_code != 0) {
return exit_code; return exit_code;
+26 -47
View File
@@ -82,14 +82,6 @@ enum VarDeclTag {
VarDeclTag_thread_local = GB_BIT(0), VarDeclTag_thread_local = GB_BIT(0),
}; };
enum TypeFlag : u32 {
TypeFlag_thread_local = GB_BIT(0),
TypeFlag_volatile = GB_BIT(1),
TypeFlag_atomic = GB_BIT(2),
};
enum StmtStateFlag : u32 { enum StmtStateFlag : u32 {
StmtStateFlag_bounds_check = GB_BIT(0), StmtStateFlag_bounds_check = GB_BIT(0),
StmtStateFlag_no_bounds_check = GB_BIT(1), StmtStateFlag_no_bounds_check = GB_BIT(1),
@@ -325,20 +317,23 @@ String const ast_node_strings[] = {
#undef AST_NODE_KIND #undef AST_NODE_KIND
}; };
#define AST_NODE_KIND(_kind_name_, name, ...) typedef __VA_ARGS__ GB_JOIN2(AstNode, _kind_name_);
AST_NODE_KINDS
#undef AST_NODE_KIND
struct AstNode { struct AstNode {
AstNodeKind kind; AstNodeKind kind;
// AstNode *prev, *next; // NOTE(bill): allow for Linked list // AstNode *prev, *next; // NOTE(bill): allow for Linked list
u32 type_flags;
u32 stmt_state_flags; u32 stmt_state_flags;
union { union {
#define AST_NODE_KIND(_kind_name_, name, ...) __VA_ARGS__ _kind_name_; #define AST_NODE_KIND(_kind_name_, name, ...) GB_JOIN2(AstNode, _kind_name_) _kind_name_;
AST_NODE_KINDS AST_NODE_KINDS
#undef AST_NODE_KIND #undef AST_NODE_KIND
}; };
}; };
#define ast_node(n_, Kind_, node_) auto *n_ = &(node_)->Kind_; GB_ASSERT((node_)->kind == GB_JOIN2(AstNode_, Kind_)) #define ast_node(n_, Kind_, node_) GB_JOIN2(AstNode, Kind_) *n_ = &(node_)->Kind_; GB_ASSERT((node_)->kind == GB_JOIN2(AstNode_, Kind_))
#define case_ast_node(n_, Kind_, node_) case GB_JOIN2(AstNode_, Kind_): { ast_node(n_, Kind_, node_); #define case_ast_node(n_, Kind_, node_) case GB_JOIN2(AstNode_, Kind_): { ast_node(n_, Kind_, node_);
#define case_end } break; #define case_end } break;
@@ -371,7 +366,10 @@ Token ast_node_token(AstNode *node) {
case AstNode_ProcLit: case AstNode_ProcLit:
return ast_node_token(node->ProcLit.type); return ast_node_token(node->ProcLit.type);
case AstNode_CompoundLit: case AstNode_CompoundLit:
return ast_node_token(node->CompoundLit.type); if (node->CompoundLit.type != NULL) {
return ast_node_token(node->CompoundLit.type);
}
return node->CompoundLit.open;
case AstNode_TagExpr: case AstNode_TagExpr:
return node->TagExpr.token; return node->TagExpr.token;
case AstNode_BadExpr: case AstNode_BadExpr:
@@ -1964,14 +1962,6 @@ AstNodeArray parse_struct_params(AstFile *f, isize *decl_count_, b32 using_allow
AstNode *parse_identifier_or_type(AstFile *f, u32 flags) { AstNode *parse_identifier_or_type(AstFile *f, u32 flags) {
switch (f->curr_token.kind) { switch (f->curr_token.kind) {
case Token_volatile:
next_token(f);
return parse_identifier_or_type(f, flags | TypeFlag_volatile);
case Token_atomic:
next_token(f);
return parse_identifier_or_type(f, flags | TypeFlag_atomic);
case Token_Identifier: { case Token_Identifier: {
AstNode *e = parse_identifier(f); AstNode *e = parse_identifier(f);
while (f->curr_token.kind == Token_Period) { while (f->curr_token.kind == Token_Period) {
@@ -1984,15 +1974,11 @@ AstNode *parse_identifier_or_type(AstFile *f, u32 flags) {
// HACK NOTE(bill): For type_of_val(expr) // HACK NOTE(bill): For type_of_val(expr)
e = parse_call_expr(f, e); e = parse_call_expr(f, e);
} }
e->type_flags = flags;
return e; return e;
} }
case Token_Pointer: { case Token_Pointer:
AstNode *e = make_pointer_type(f, expect_token(f, Token_Pointer), parse_type(f)); return make_pointer_type(f, expect_token(f, Token_Pointer), parse_type(f));
e->type_flags = flags;
return e;
}
case Token_OpenBracket: { case Token_OpenBracket: {
f->expr_level++; f->expr_level++;
@@ -2008,7 +1994,6 @@ AstNode *parse_identifier_or_type(AstFile *f, u32 flags) {
expect_token(f, Token_CloseBracket); expect_token(f, Token_CloseBracket);
f->expr_level--; f->expr_level--;
AstNode *e = make_array_type(f, token, count_expr, parse_type(f)); AstNode *e = make_array_type(f, token, count_expr, parse_type(f));
e->type_flags = flags;
return e; return e;
} }
@@ -2018,9 +2003,7 @@ AstNode *parse_identifier_or_type(AstFile *f, u32 flags) {
AstNode *count_expr = parse_expr(f, false); AstNode *count_expr = parse_expr(f, false);
expect_token(f, Token_CloseBrace); expect_token(f, Token_CloseBrace);
f->expr_level--; f->expr_level--;
AstNode *e = make_vector_type(f, token, count_expr, parse_type(f)); return make_vector_type(f, token, count_expr, parse_type(f));
e->type_flags = flags;
return e;
} }
case Token_struct: { case Token_struct: {
@@ -2030,11 +2013,17 @@ AstNode *parse_identifier_or_type(AstFile *f, u32 flags) {
while (allow_token(f, Token_Hash)) { while (allow_token(f, Token_Hash)) {
Token tag = expect_token(f, Token_Identifier); Token tag = expect_token(f, Token_Identifier);
if (tag.string == "packed") { if (tag.string == "packed") {
if (is_packed) {
syntax_error(tag, "Duplicate struct tag `#%.*s`", LIT(tag.string));
}
is_packed = true; is_packed = true;
} else if (tag.string == "ordered") { } else if (tag.string == "ordered") {
if (is_ordered) {
syntax_error(tag, "Duplicate struct tag `#%.*s`", LIT(tag.string));
}
is_ordered = true; is_ordered = true;
} else { } else {
syntax_error(tag, "Expected a `#packed` or `#ordered` tag"); syntax_error(tag, "Invalid struct tag `#%.*s`", LIT(tag.string));
} }
} }
@@ -2047,9 +2036,7 @@ AstNode *parse_identifier_or_type(AstFile *f, u32 flags) {
AstNodeArray decls = parse_struct_params(f, &decl_count, true); AstNodeArray decls = parse_struct_params(f, &decl_count, true);
Token close = expect_token(f, Token_CloseBrace); Token close = expect_token(f, Token_CloseBrace);
AstNode *e = make_struct_type(f, token, decls, decl_count, is_packed, is_ordered); return make_struct_type(f, token, decls, decl_count, is_packed, is_ordered);
e->type_flags = flags;
return e;
} break; } break;
case Token_union: { case Token_union: {
@@ -2059,9 +2046,7 @@ AstNode *parse_identifier_or_type(AstFile *f, u32 flags) {
AstNodeArray decls = parse_struct_params(f, &decl_count, false); AstNodeArray decls = parse_struct_params(f, &decl_count, false);
Token close = expect_token(f, Token_CloseBrace); Token close = expect_token(f, Token_CloseBrace);
AstNode *e = make_union_type(f, token, decls, decl_count); return make_union_type(f, token, decls, decl_count);
e->type_flags = flags;
return e;
} }
case Token_raw_union: { case Token_raw_union: {
@@ -2071,9 +2056,7 @@ AstNode *parse_identifier_or_type(AstFile *f, u32 flags) {
AstNodeArray decls = parse_struct_params(f, &decl_count, true); AstNodeArray decls = parse_struct_params(f, &decl_count, true);
Token close = expect_token(f, Token_CloseBrace); Token close = expect_token(f, Token_CloseBrace);
AstNode *e = make_raw_union_type(f, token, decls, decl_count); return make_raw_union_type(f, token, decls, decl_count);
e->type_flags = flags;
return e;
} }
case Token_enum: { case Token_enum: {
@@ -2108,9 +2091,7 @@ AstNode *parse_identifier_or_type(AstFile *f, u32 flags) {
close = expect_token(f, Token_CloseBrace); close = expect_token(f, Token_CloseBrace);
AstNode *e = make_enum_type(f, token, base_type, fields); return make_enum_type(f, token, base_type, fields);
e->type_flags = flags;
return e;
} }
case Token_proc: { case Token_proc: {
@@ -2121,7 +2102,6 @@ AstNode *parse_identifier_or_type(AstFile *f, u32 flags) {
return type; return type;
} }
case Token_OpenParen: { case Token_OpenParen: {
// NOTE(bill): Skip the paren expression // NOTE(bill): Skip the paren expression
AstNode *type; AstNode *type;
@@ -2129,9 +2109,8 @@ AstNode *parse_identifier_or_type(AstFile *f, u32 flags) {
open = expect_token(f, Token_OpenParen); open = expect_token(f, Token_OpenParen);
type = parse_type(f); type = parse_type(f);
close = expect_token(f, Token_CloseParen); close = expect_token(f, Token_CloseParen);
AstNode *e = make_paren_expr(f, type, open, close); return type;
e->type_flags = flags; // return make_paren_expr(f, type, open, close);
return e;
} }
// TODO(bill): Why is this even allowed? Is this a parsing error? // TODO(bill): Why is this even allowed? Is this a parsing error?