mirror of
https://github.com/odin-lang/Odin.git
synced 2026-10-13 03:27:44 -04:00
Add @(align=N) for variables, raising the alignment of globals, locals, @(static) and @(thread_local) variables to at least N
This commit is contained in:
1 parent
30f80e1079
commit
5ff7268cab
8 files changed
+35
-5
No files matched your search
@@ -4653,6 +4653,24 @@ gb_internal DECL_ATTRIBUTE_PROC(var_decl_attribute) {
|
||||
error(elem, "Expected either no value or a string for '%.*s'", LIT(name));
|
||||
}
|
||||
return true;
|
||||
} else if (name == "align") {
|
||||
ExactValue ev = check_decl_attribute_value(c, value);
|
||||
if (ev.kind != ExactValue_Integer) {
|
||||
error(elem, "Expected a constant integer for '%.*s'", LIT(name));
|
||||
return true;
|
||||
}
|
||||
i64 align = exact_value_to_i64(ev);
|
||||
if (ev.value_integer.used > 1 ||
|
||||
align < 1 ||
|
||||
align > (1ll<<31) ||
|
||||
!gb_is_power_of_two(cast(isize)align)) {
|
||||
gbString str = exact_value_to_string(ev);
|
||||
error(elem, "'%.*s' must be a power of 2 no greater than 2^31, got %s", LIT(name), str);
|
||||
gb_string_free(str);
|
||||
} else {
|
||||
ac->align = align;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
if (c->curr_proc_decl != nullptr) {
|
||||
|
||||
Reference in new issue
Block a user