aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorriChar <wxsychi@163.com>2022-09-04 23:44:45 +0800
committerGitHub <noreply@github.com>2022-09-04 18:44:45 +0300
commit349cf54b3293bc4177253e96a4f84fea0251fa08 (patch)
tree5d10e1ca26ee49a5121a18aa5dffc269bd729277 /test
parentb7d5582dede8f4cae341365ac9c47c840bd80eff (diff)
downloadzig-349cf54b3293bc4177253e96a4f84fea0251fa08.tar.gz
zig-349cf54b3293bc4177253e96a4f84fea0251fa08.zip
llvm: fix the `type` parameter of `GlobalAlias`
Closes 12680
Diffstat (limited to 'test')
-rw-r--r--test/behavior.zig1
-rw-r--r--test/behavior/bugs/12680.zig17
-rw-r--r--test/behavior/bugs/12680_other_file.zig8
3 files changed, 26 insertions, 0 deletions
diff --git a/test/behavior.zig b/test/behavior.zig
index 8f581f372e..4b55913af5 100644
--- a/test/behavior.zig
+++ b/test/behavior.zig
@@ -85,6 +85,7 @@ test {
_ = @import("behavior/bugs/12033.zig");
_ = @import("behavior/bugs/12430.zig");
_ = @import("behavior/bugs/12486.zig");
+ _ = @import("behavior/bugs/12680.zig");
_ = @import("behavior/byteswap.zig");
_ = @import("behavior/byval_arg_var.zig");
_ = @import("behavior/call.zig");
diff --git a/test/behavior/bugs/12680.zig b/test/behavior/bugs/12680.zig
new file mode 100644
index 0000000000..c7bd8f63aa
--- /dev/null
+++ b/test/behavior/bugs/12680.zig
@@ -0,0 +1,17 @@
+const std = @import("std");
+const expectEqual = std.testing.expectEqual;
+const other_file = @import("12680_other_file.zig");
+const builtin = @import("builtin");
+
+extern fn test_func() callconv(.C) usize;
+
+test "export a function twice" {
+ if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
+ if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
+ if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
+ if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest;
+ if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
+
+ // If it exports the function correctly, `test_func` and `testFunc` will points to the same address.
+ try expectEqual(test_func(), other_file.testFunc());
+}
diff --git a/test/behavior/bugs/12680_other_file.zig b/test/behavior/bugs/12680_other_file.zig
new file mode 100644
index 0000000000..32b9dc1b27
--- /dev/null
+++ b/test/behavior/bugs/12680_other_file.zig
@@ -0,0 +1,8 @@
+// export this function twice
+pub export fn testFunc() callconv(.C) usize {
+ return @ptrToInt(&testFunc);
+}
+
+comptime {
+ @export(testFunc, .{ .name = "test_func", .linkage = .Strong });
+}