diff options
| author | gingerBill <bill@gingerbill.org> | 2017-11-03 23:46:42 +0000 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2017-11-03 23:46:42 +0000 |
| commit | 121f0185d6923c84d64ee75326d15013eb5d1fe0 (patch) | |
| tree | efdd5144c55a761d2f9a81f5d04f4fed264661d6 /src/check_decl.cpp | |
| parent | e7999f8450aca9c4c81e272470be438e6a183939 (diff) | |
Custom thread local models
Diffstat (limited to 'src/check_decl.cpp')
| -rw-r--r-- | src/check_decl.cpp | 21 |
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) { |