diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2019-02-26 19:42:39 -0500 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2019-02-26 19:43:12 -0500 |
| commit | 557983e5020d0a28dba1f63ee9e515c6b779bfd4 (patch) | |
| tree | 2fd2b3b2715d99eba024e0c6d27fe5cf29c9be38 /src/ir.cpp | |
| parent | 763357c9c3e8feba34a932c60b55f2224989f2d4 (diff) | |
| download | zig-557983e5020d0a28dba1f63ee9e515c6b779bfd4.tar.gz zig-557983e5020d0a28dba1f63ee9e515c6b779bfd4.zip | |
fix handling when there are multiple externs and
an export in the same object
closes #529
Diffstat (limited to 'src/ir.cpp')
| -rw-r--r-- | src/ir.cpp | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/ir.cpp b/src/ir.cpp index d59acb7015..87e03ea519 100644 --- a/src/ir.cpp +++ b/src/ir.cpp @@ -13279,12 +13279,21 @@ static IrInstruction *ir_analyze_instruction_export(IrAnalyze *ira, IrInstructio } } - auto entry = ira->codegen->exported_symbol_names.put_unique(symbol_name, instruction->base.source_node); + // TODO: This function needs to be audited. + // It's not clear how all the different types are supposed to be handled. + // Need comprehensive tests for exporting one thing in one file and declaring an extern var + // in another file. + TldFn *tld_fn = allocate<TldFn>(1); + tld_fn->base.id = TldIdFn; + tld_fn->base.source_node = instruction->base.source_node; + + auto entry = ira->codegen->exported_symbol_names.put_unique(symbol_name, &tld_fn->base); if (entry) { - AstNode *other_export_node = entry->value; + AstNode *other_export_node = entry->value->source_node; ErrorMsg *msg = ir_add_error(ira, &instruction->base, buf_sprintf("exported symbol collision: '%s'", buf_ptr(symbol_name))); add_error_note(ira->codegen, msg, other_export_node, buf_sprintf("other symbol is here")); + return ira->codegen->invalid_instruction; } bool want_var_export = false; @@ -13295,6 +13304,7 @@ static IrInstruction *ir_analyze_instruction_export(IrAnalyze *ira, IrInstructio case ZigTypeIdFn: { assert(target->value.data.x_ptr.special == ConstPtrSpecialFunction); ZigFn *fn_entry = target->value.data.x_ptr.data.fn.fn_entry; + tld_fn->fn_entry = fn_entry; CallingConvention cc = fn_entry->type_entry->data.fn.fn_type_id.cc; switch (cc) { case CallingConventionUnspecified: { |
