From 42ea2d0d1c3b8cafdfc9a383cbb1bab274eb0140 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Fri, 14 Jun 2019 15:20:52 -0400 Subject: fix `@export` for arrays and allow sections on extern variables previously `@export` for an array would panic with a TODO message. now it will do the export. However, it uses the variable's name rather than the name passed to `@export`. Issue #2679 remains open for that problem. --- src/analyze.cpp | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) (limited to 'src/analyze.cpp') diff --git a/src/analyze.cpp b/src/analyze.cpp index cbf293c7fe..04665cc53b 100644 --- a/src/analyze.cpp +++ b/src/analyze.cpp @@ -2780,12 +2780,7 @@ static void resolve_decl_fn(CodeGen *g, TldFn *tld_fn) { fn_table_entry->type_entry = analyze_fn_type(g, source_node, child_scope, fn_table_entry); if (fn_proto->section_expr != nullptr) { - if (fn_table_entry->body_node == nullptr) { - add_node_error(g, fn_proto->section_expr, - buf_sprintf("cannot set section of external function '%s'", buf_ptr(&fn_table_entry->symbol_name))); - } else { - analyze_const_string(g, child_scope, fn_proto->section_expr, &fn_table_entry->section_name); - } + analyze_const_string(g, child_scope, fn_proto->section_expr, &fn_table_entry->section_name); } if (fn_table_entry->type_entry->id == ZigTypeIdInvalid) { @@ -3258,10 +3253,7 @@ static void resolve_decl_var(CodeGen *g, TldVar *tld_var) { } if (var_decl->section_expr != nullptr) { - if (var_decl->is_extern) { - add_node_error(g, var_decl->section_expr, - buf_sprintf("cannot set section of external variable '%s'", buf_ptr(var_decl->symbol))); - } else if (!analyze_const_string(g, tld_var->base.parent_scope, var_decl->section_expr, &tld_var->section_name)) { + if (!analyze_const_string(g, tld_var->base.parent_scope, var_decl->section_expr, &tld_var->section_name)) { tld_var->section_name = nullptr; } } -- cgit v1.2.3