authorgravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2022-10-06 06:33:21-04:00
committergravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2022-10-25 05:11:28-04:00
log45c667eb21b1edde991435871523ece82793b449
tree93519b7479f61b345dcdcc4677b867a54a31be8f
parente875530f8f886cbf8272ab18d063252b94a835c9

behavior: fix redefined exports


4 files changed, 11 insertions(+), 23 deletions(-)

test/behavior.zig+1-7
...@@ -211,13 +211,7 @@ test {...@@ -211,13 +211,7 @@ test {
211 _ = @import("behavior/export.zig");211 _ = @import("behavior/export.zig");
212 }212 }
213213
214 if (builtin.zig_backend != .stage2_arm and214 if (builtin.zig_backend != .stage2_wasm) {
215 builtin.zig_backend != .stage2_x86_64 and
216 builtin.zig_backend != .stage2_aarch64 and
217 builtin.zig_backend != .stage2_wasm and
218 builtin.zig_backend != .stage2_c and
219 builtin.zig_backend != .stage1)
220 {
221 _ = @import("behavior/export_self_referential_type_info.zig");215 _ = @import("behavior/export_self_referential_type_info.zig");
222 }216 }
223}217}
test/behavior/export_self_referential_type_info.zig+1-1
...@@ -1 +1 @@...@@ -1 +1 @@
1export const foo: c_int = @boolToInt(@typeInfo(@This()).Struct.is_tuple);1export const self_referential_type_info: c_int = @boolToInt(@typeInfo(@This()).Struct.is_tuple);
test/behavior/generics.zig+5-4
...@@ -361,13 +361,14 @@ test "nested generic function" {...@@ -361,13 +361,14 @@ test "nested generic function" {
361361
362test "extern function used as generic parameter" {362test "extern function used as generic parameter" {
363 const S = struct {363 const S = struct {
364 extern fn foo() void;364 extern fn usedAsGenericParameterFoo() void;
365 extern fn bar() void;365 extern fn usedAsGenericParameterBar() void;
366 inline fn baz(comptime _: anytype) type {366 inline fn usedAsGenericParameterBaz(comptime _: anytype) type {
367 return struct {};367 return struct {};
368 }368 }
369 };369 };
370 try expect(S.baz(S.foo) != S.baz(S.bar));370 try expect(S.usedAsGenericParameterBaz(S.usedAsGenericParameterFoo) !=
371 S.usedAsGenericParameterBaz(S.usedAsGenericParameterBar));
371}372}
372373
373test "generic struct as parameter type" {374test "generic struct as parameter type" {
test/behavior/type_info.zig+4-11
...@@ -355,19 +355,12 @@ fn testOpaque() !void {...@@ -355,19 +355,12 @@ fn testOpaque() !void {
355}355}
356356
357test "type info: function type info" {357test "type info: function type info" {
358 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
359 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
360 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
361
362 // wasm doesn't support align attributes on functions
363 if (builtin.target.cpu.arch == .wasm32 or builtin.target.cpu.arch == .wasm64) return error.SkipZigTest;
364
365 try testFunction();358 try testFunction();
366 comptime try testFunction();359 comptime try testFunction();
367}360}
368361
369fn testFunction() !void {362fn testFunction() !void {
370 const fn_info = @typeInfo(@TypeOf(foo));363 const fn_info = @typeInfo(@TypeOf(typeInfoFoo));
371 try expect(fn_info == .Fn);364 try expect(fn_info == .Fn);
372 try expect(fn_info.Fn.alignment > 0);365 try expect(fn_info.Fn.alignment > 0);
373 try expect(fn_info.Fn.calling_convention == .C);366 try expect(fn_info.Fn.calling_convention == .C);
...@@ -375,12 +368,12 @@ fn testFunction() !void {...@@ -375,12 +368,12 @@ fn testFunction() !void {
375 try expect(fn_info.Fn.args.len == 2);368 try expect(fn_info.Fn.args.len == 2);
376 try expect(fn_info.Fn.is_var_args);369 try expect(fn_info.Fn.is_var_args);
377 try expect(fn_info.Fn.return_type.? == usize);370 try expect(fn_info.Fn.return_type.? == usize);
378 const fn_aligned_info = @typeInfo(@TypeOf(fooAligned));371 const fn_aligned_info = @typeInfo(@TypeOf(typeInfoFooAligned));
379 try expect(fn_aligned_info.Fn.alignment == 4);372 try expect(fn_aligned_info.Fn.alignment == 4);
380}373}
381374
382extern fn foo(a: usize, b: bool, ...) callconv(.C) usize;375extern fn typeInfoFoo(a: usize, b: bool, ...) callconv(.C) usize;
383extern fn fooAligned(a: usize, b: bool, ...) align(4) callconv(.C) usize;376extern fn typeInfoFooAligned(a: usize, b: bool, ...) align(4) callconv(.C) usize;
384377
385test "type info: generic function types" {378test "type info: generic function types" {
386 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;379 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;