From 121f0185d6923c84d64ee75326d15013eb5d1fe0 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Fri, 3 Nov 2017 23:46:42 +0000 Subject: Custom thread local models --- src/check_decl.cpp | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'src/check_decl.cpp') 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) { -- cgit v1.2.3