diff options
| author | gingerBill <bill@gingerbill.org> | 2020-10-01 12:02:07 +0100 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2020-10-01 12:02:07 +0100 |
| commit | dd4c02a1b95054891880cb17c9c10a43686a614c (patch) | |
| tree | a83071decae96f683471baa6967b0afddf2ab51a /src/ir.cpp | |
| parent | bc2151f529e11b656d112fb5c510470674167d7e (diff) | |
Fix multiple declared foreign procedures
Diffstat (limited to 'src/ir.cpp')
| -rw-r--r-- | src/ir.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/ir.cpp b/src/ir.cpp index e9be81eb8..9882e9c50 100644 --- a/src/ir.cpp +++ b/src/ir.cpp @@ -7806,6 +7806,18 @@ irValue *ir_build_expr_internal(irProcedure *proc, Ast *expr) { Entity *e = entity_from_expr(expr); e = strip_entity_wrapping(e); GB_ASSERT(e != nullptr); + if (e->kind == Entity_Procedure && e->Procedure.is_foreign) { + // NOTE(bill): There can be duplicates of the foreign procedure; get the main one + String link_name = e->token.string; + if (e->Procedure.link_name.len != 0) { + link_name = e->Procedure.link_name; + } + auto *found = string_map_get(&proc->module->members, link_name); + if (found) { + return *found; + } + } + auto *found = map_get(&proc->module->values, hash_entity(e)); if (found) { auto v = *found; |