mirror of
https://github.com/odin-lang/Odin.git
synced 2026-01-03 19:52:30 +00:00
Fix alignment for normal structures to match LLVM
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
#import "fmt.odin";
|
||||
// #import "fmt.odin";
|
||||
#import "strings.odin";
|
||||
|
||||
Handle :: i32;
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#import win32 "sys/windows.odin";
|
||||
#import fmt "fmt.odin";
|
||||
|
||||
Handle :: int;
|
||||
File_Time :: u64;
|
||||
|
||||
@@ -3126,6 +3126,7 @@ Entity *check_selector(Checker *c, Operand *operand, AstNode *node, Type *type_h
|
||||
|
||||
Entity **procs = gb_alloc_array(heap_allocator(), Entity *, overload_count);
|
||||
map_entity_multi_get_all(&import_scope->elements, key, procs);
|
||||
|
||||
for (isize i = 0; i < overload_count; i++) {
|
||||
Type *t = base_type(procs[i]->type);
|
||||
if (t == t_invalid) {
|
||||
|
||||
@@ -1797,7 +1797,6 @@ void check_import_entities(Checker *c, MapScope *file_scopes) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!previously_added) {
|
||||
array_add(&parent_scope->imported, scope);
|
||||
} else {
|
||||
@@ -1813,19 +1812,21 @@ void check_import_entities(Checker *c, MapScope *file_scopes) {
|
||||
if (e->scope == parent_scope) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
if (!is_entity_kind_exported(e->kind)) {
|
||||
continue;
|
||||
}
|
||||
if (id->is_import) {
|
||||
if (is_entity_exported(e)) {
|
||||
// TODO(bill): Should these entities be imported but cause an error when used?
|
||||
bool ok = add_entity(c, parent_scope, NULL, e);
|
||||
bool ok = add_entity(c, parent_scope, e->identifier, e);
|
||||
if (ok) {
|
||||
map_bool_set(&parent_scope->implicit, hash_pointer(e), true);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
add_entity(c, parent_scope, NULL, e);
|
||||
add_entity(c, parent_scope, e->identifier, e);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
36
src/types.c
36
src/types.c
@@ -1614,31 +1614,23 @@ i64 type_align_of_internal(gbAllocator allocator, Type *t, TypePath *path) {
|
||||
return gb_clamp(t->Record.custom_align, 1, build_context.max_align);
|
||||
}
|
||||
if (t->Record.field_count > 0) {
|
||||
// TODO(bill): What is this supposed to be?
|
||||
i64 max = 1;
|
||||
if (t->Record.is_packed) {
|
||||
i64 max = build_context.word_size;
|
||||
for (isize i = 0; i < t->Record.field_count; i++) {
|
||||
Type *field_type = t->Record.fields[i]->type;
|
||||
type_path_push(path, field_type);
|
||||
if (path->failure) {
|
||||
return FAILURE_ALIGNMENT;
|
||||
}
|
||||
i64 align = type_align_of_internal(allocator, field_type, path);
|
||||
type_path_pop(path);
|
||||
if (max < align) {
|
||||
max = align;
|
||||
}
|
||||
max = build_context.word_size;
|
||||
}
|
||||
for (isize i = 0; i < t->Record.field_count; i++) {
|
||||
Type *field_type = t->Record.fields[i]->type;
|
||||
type_path_push(path, field_type);
|
||||
if (path->failure) {
|
||||
return FAILURE_ALIGNMENT;
|
||||
}
|
||||
i64 align = type_align_of_internal(allocator, field_type, path);
|
||||
type_path_pop(path);
|
||||
if (max < align) {
|
||||
max = align;
|
||||
}
|
||||
return max;
|
||||
}
|
||||
Type *field_type = t->Record.fields[0]->type;
|
||||
type_path_push(path, field_type);
|
||||
if (path->failure) {
|
||||
return FAILURE_ALIGNMENT;
|
||||
}
|
||||
i64 align = type_align_of_internal(allocator, field_type, path);
|
||||
type_path_pop(path);
|
||||
return align;
|
||||
return max;
|
||||
}
|
||||
break;
|
||||
case TypeRecord_Union: {
|
||||
|
||||
Reference in New Issue
Block a user