aboutsummaryrefslogtreecommitdiff
path: root/src/analyze.cpp
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2019-06-14 15:20:52 -0400
committerAndrew Kelley <andrew@ziglang.org>2019-06-14 15:28:52 -0400
commit42ea2d0d1c3b8cafdfc9a383cbb1bab274eb0140 (patch)
treeb4cda1880f432c47c228747c356200b01604bafb /src/analyze.cpp
parent9e8db5b7505a6c2e601c8a94b9d8a4282b5df184 (diff)
downloadzig-42ea2d0d1c3b8cafdfc9a383cbb1bab274eb0140.tar.gz
zig-42ea2d0d1c3b8cafdfc9a383cbb1bab274eb0140.zip
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.
Diffstat (limited to 'src/analyze.cpp')
-rw-r--r--src/analyze.cpp12
1 files changed, 2 insertions, 10 deletions
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;
}
}