aboutsummaryrefslogtreecommitdiff
path: root/src/check_decl.cpp
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2024-06-06 15:16:34 +0100
committergingerBill <bill@gingerbill.org>2024-06-06 15:16:34 +0100
commit9ef43fc782159893b7af139f9d9be3aec3108ecd (patch)
treeb1da3f8f421d997de2a0c966b3efe87a96f563eb /src/check_decl.cpp
parent971229fe66cdc93135e0f7e41cdf2a0bce28cd67 (diff)
Add `@(rodata)`
Diffstat (limited to 'src/check_decl.cpp')
-rw-r--r--src/check_decl.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/check_decl.cpp b/src/check_decl.cpp
index f2afce59c..43947836b 100644
--- a/src/check_decl.cpp
+++ b/src/check_decl.cpp
@@ -1264,6 +1264,9 @@ gb_internal void check_global_variable_decl(CheckerContext *ctx, Entity *&e, Ast
if (ac.is_static) {
error(e->token, "@(static) is not supported for global variables, nor required");
}
+ if (ac.rodata) {
+ e->Variable.is_rodata = true;
+ }
ac.link_name = handle_link_name(ctx, e->token, ac.link_name, ac.link_prefix, ac.link_suffix);
if (is_arch_wasm() && e->Variable.thread_local_model.len != 0) {
@@ -1350,6 +1353,9 @@ gb_internal void check_global_variable_decl(CheckerContext *ctx, Entity *&e, Ast
Operand o = {};
check_expr_with_type_hint(ctx, &o, init_expr, e->type);
check_init_variable(ctx, e, &o, str_lit("variable declaration"));
+ if (e->Variable.is_rodata && o.mode != Addressing_Constant) {
+ error(o.expr, "Variables declared with @(rodata) must have constant initialization");
+ }
check_rtti_type_disallowed(e->token, e->type, "A variable declaration is using a type, %s, which has been disallowed");
}