mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-01 12:18:15 +00:00
Allow @(rodata) on @(static) variables
This commit is contained in:
+5
-1
@@ -2059,7 +2059,11 @@ gb_internal void check_value_decl_stmt(CheckerContext *ctx, Ast *node, u32 mod_f
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ac.rodata) {
|
if (ac.rodata) {
|
||||||
error(e->token, "Only global variables can have @(rodata) applied");
|
if (ac.is_static) {
|
||||||
|
e->Variable.is_rodata = true;
|
||||||
|
} else {
|
||||||
|
error(e->token, "Only global or @(static) variables can have @(rodata) applied");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (ac.thread_local_model != "") {
|
if (ac.thread_local_model != "") {
|
||||||
String name = e->token.string;
|
String name = e->token.string;
|
||||||
|
|||||||
@@ -1850,7 +1850,9 @@ gb_internal void lb_build_static_variables(lbProcedure *p, AstValueDecl *vd) {
|
|||||||
LLVMSetInitializer(global, LLVMConstNull(lb_type(p->module, e->type)));
|
LLVMSetInitializer(global, LLVMConstNull(lb_type(p->module, e->type)));
|
||||||
if (value.value != nullptr) {
|
if (value.value != nullptr) {
|
||||||
LLVMSetInitializer(global, value.value);
|
LLVMSetInitializer(global, value.value);
|
||||||
} else {
|
}
|
||||||
|
if (e->Variable.is_rodata) {
|
||||||
|
LLVMSetGlobalConstant(global, true);
|
||||||
}
|
}
|
||||||
if (e->Variable.thread_local_model != "") {
|
if (e->Variable.thread_local_model != "") {
|
||||||
LLVMSetThreadLocal(global, true);
|
LLVMSetThreadLocal(global, true);
|
||||||
|
|||||||
Reference in New Issue
Block a user