aboutsummaryrefslogtreecommitdiff
path: root/src/codegen
diff options
context:
space:
mode:
authorVeikka Tuominen <git@vexu.eu>2022-03-21 13:25:57 +0200
committerAndrew Kelley <andrew@ziglang.org>2022-03-21 15:12:32 -0400
commit0577069af5f5deb859762725736537d60c324453 (patch)
treef57aaa7713101bd2cabc82f505bdd156a988ac04 /src/codegen
parentb48d8cce52369e7625f9dab8a37efe9c3a33186b (diff)
downloadzig-0577069af5f5deb859762725736537d60c324453.tar.gz
zig-0577069af5f5deb859762725736537d60c324453.zip
stage2 llvm: fix lowerDeclRefValue for function aliases
Diffstat (limited to 'src/codegen')
-rw-r--r--src/codegen/llvm.zig11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/codegen/llvm.zig b/src/codegen/llvm.zig
index 2d5b38eb17..3837679b0a 100644
--- a/src/codegen/llvm.zig
+++ b/src/codegen/llvm.zig
@@ -3073,6 +3073,17 @@ pub const DeclGen = struct {
return self.context.constStruct(&fields, fields.len, .False);
}
+ // In the case of something like:
+ // fn foo() void {}
+ // const bar = foo;
+ // ... &bar;
+ // `bar` is just an alias and we actually want to lower a reference to `foo`.
+ if (decl.val.castTag(.function)) |func| {
+ if (func.data.owner_decl != decl) {
+ return self.lowerDeclRefValue(tv, func.data.owner_decl);
+ }
+ }
+
const is_fn_body = decl.ty.zigTypeTag() == .Fn;
if (!is_fn_body and !decl.ty.hasRuntimeBitsIgnoreComptime()) {
return self.lowerPtrToVoid(tv.ty);