aboutsummaryrefslogtreecommitdiff
path: root/src/check_decl.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/check_decl.cpp')
-rw-r--r--src/check_decl.cpp21
1 files changed, 14 insertions, 7 deletions
diff --git a/src/check_decl.cpp b/src/check_decl.cpp
index 813028ab1..b38575e24 100644
--- a/src/check_decl.cpp
+++ b/src/check_decl.cpp
@@ -761,16 +761,23 @@ void check_var_decl(Checker *c, Entity *e, Entity **entities, isize entity_count
error(elem, "Expected a string value for `%.*s`", LIT(name));
}
} else if (name == "thread_local") {
- if (ev.kind == ExactValue_Invalid) {
- if (!e->scope->is_file) {
- error(elem, "Only a variable at file scope can be thread local");
- } else if (init_expr_list.count > 0) {
- error(elem, "A thread local variable declaration cannot have initialization values");
+ if (!e->scope->is_file) {
+ error(elem, "Only a variable at file scope can be thread local");
+ } else if (init_expr_list.count > 0) {
+ error(elem, "A thread local variable declaration cannot have initialization values");
+ } else if (ev.kind == ExactValue_Invalid) {
+ e->Variable.thread_local_model = str_lit("default");
+ } else if (ev.kind == ExactValue_String) {
+ String model = ev.value_string;
+ if (model == "localdynamic" ||
+ model == "initialexec" ||
+ model == "localexec") {
+ e->Variable.thread_local_model = model;
} else {
- e->Variable.is_thread_local = true;
+ error(elem, "Invalid thread local model `%.*s`", LIT(model));
}
} else {
- error(elem, "Expected no value for `%.*s`", LIT(name));
+ error(elem, "Expected either no value or a string for `%.*s`", LIT(name));
}
} else if (name == "link_prefix") {
if (ev.kind == ExactValue_String) {