aboutsummaryrefslogtreecommitdiff
path: root/src/ir.cpp
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2019-06-14 17:23:24 -0400
committerAndrew Kelley <andrew@ziglang.org>2019-06-14 17:23:24 -0400
commitf8f054b354088eb9e76d9207972022bc1d3dfc28 (patch)
treea45396b18548f911ae88067c98c9c5afd1ad3358 /src/ir.cpp
parent42ea2d0d1c3b8cafdfc9a383cbb1bab274eb0140 (diff)
downloadzig-f8f054b354088eb9e76d9207972022bc1d3dfc28.tar.gz
zig-f8f054b354088eb9e76d9207972022bc1d3dfc28.zip
fix `@export` for arrays not respecting the symbol name
Previously, the symbol name parameter of `@export` would be ignored for variables, and the variable name would be used for the symbol name. Now it works as expected. See #2679
Diffstat (limited to 'src/ir.cpp')
-rw-r--r--src/ir.cpp18
1 files changed, 2 insertions, 16 deletions
diff --git a/src/ir.cpp b/src/ir.cpp
index a1227fbd93..6c1c84da3b 100644
--- a/src/ir.cpp
+++ b/src/ir.cpp
@@ -13791,20 +13791,6 @@ static IrInstruction *ir_analyze_instruction_decl_var(IrAnalyze *ira,
return ir_build_var_decl_gen(ira, &decl_var_instruction->base, var, casted_init_value);
}
-static VarLinkage global_linkage_to_var_linkage(GlobalLinkageId id) {
- switch (id) {
- case GlobalLinkageIdStrong:
- return VarLinkageExportStrong;
- case GlobalLinkageIdWeak:
- return VarLinkageExportWeak;
- case GlobalLinkageIdLinkOnce:
- return VarLinkageExportLinkOnce;
- case GlobalLinkageIdInternal:
- return VarLinkageInternal;
- }
- zig_unreachable();
-}
-
static IrInstruction *ir_analyze_instruction_export(IrAnalyze *ira, IrInstructionExport *instruction) {
IrInstruction *name = instruction->name->child;
Buf *symbol_name = ir_resolve_str(ira, name);
@@ -14002,7 +13988,7 @@ static IrInstruction *ir_analyze_instruction_export(IrAnalyze *ira, IrInstructio
if (load_ptr->ptr->id == IrInstructionIdVarPtr) {
IrInstructionVarPtr *var_ptr = reinterpret_cast<IrInstructionVarPtr *>(load_ptr->ptr);
ZigVar *var = var_ptr->var;
- var->linkage = global_linkage_to_var_linkage(global_linkage_id);
+ add_var_export(ira->codegen, var, symbol_name, global_linkage_id);
}
}
@@ -14295,7 +14281,7 @@ static IrInstruction *ir_get_var_ptr(IrAnalyze *ira, IrInstruction *instruction,
ConstExprValue *mem_slot = nullptr;
bool comptime_var_mem = ir_get_var_is_comptime(var);
- bool linkage_makes_it_runtime = var->linkage == VarLinkageExternal;
+ bool linkage_makes_it_runtime = var->decl_node->data.variable_declaration.is_extern;
bool is_const = var->src_is_const;
bool is_volatile = false;