| author | |
| committer | |
| log | fb7be4e074d1f23f708aa64cd49e8b0d9862e39a |
| tree | d7a2a61e853ba7197b4932d08f044412cefafb8d |
| parent | f78f9388fe79f084d5ea028e6270a410eacfc316 |
3 files changed, 46 insertions(+), 0 deletions(-)
test/behavior/generics.zig+5| ... | ... | @@ -381,6 +381,11 @@ test "extern function used as generic parameter" { |
| 381 | 381 | }; |
| 382 | 382 | } |
| 383 | 383 | }; |
| 384 | const E = struct { | |
| 385 | export fn usedAsGenericParameterFoo() void {} | |
| 386 | export fn usedAsGenericParameterBar() void {} | |
| 387 | }; | |
| 388 | _ = E; | |
| 384 | 389 | try expect(S.usedAsGenericParameterBaz(S.usedAsGenericParameterFoo) != |
| 385 | 390 | S.usedAsGenericParameterBaz(S.usedAsGenericParameterBar)); |
| 386 | 391 | } |
test/behavior/sizeof_and_typeof.zig+32| ... | ... | @@ -359,6 +359,30 @@ extern fn c_fputs([*c]const u8, noalias [*c]FILE) c_int; |
| 359 | 359 | extern fn c_ftell([*c]FILE) c_long; |
| 360 | 360 | extern fn c_fopen([*c]const u8, [*c]const u8) [*c]FILE; |
| 361 | 361 | |
| 362 | const exp = struct { | |
| 363 | export fn c_printf(a: [*c]const u8) c_int { | |
| 364 | _ = a; | |
| 365 | unreachable; | |
| 366 | } | |
| 367 | export fn c_fputs(a: [*c]const u8, noalias b: [*c]FILE) c_int { | |
| 368 | _ = a; | |
| 369 | _ = b; | |
| 370 | unreachable; | |
| 371 | } | |
| 372 | export fn c_ftell(a: [*c]FILE) c_long { | |
| 373 | _ = a; | |
| 374 | unreachable; | |
| 375 | } | |
| 376 | export fn c_fopen(a: [*c]const u8, b: [*c]const u8) [*c]FILE { | |
| 377 | _ = a; | |
| 378 | _ = b; | |
| 379 | unreachable; | |
| 380 | } | |
| 381 | }; | |
| 382 | comptime { | |
| 383 | _ = exp; | |
| 384 | } | |
| 385 | ||
| 362 | 386 | test "Extern function calls in @TypeOf" { |
| 363 | 387 | if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest; |
| 364 | 388 | |
| ... | ... | @@ -367,6 +391,14 @@ test "Extern function calls in @TypeOf" { |
| 367 | 391 | |
| 368 | 392 | extern fn s_do_thing([*c]const @This(), b: c_int) c_short; |
| 369 | 393 | }; |
| 394 | const E = struct { | |
| 395 | export fn s_do_thing(a: [*c]const @This(), b: c_int) c_short { | |
| 396 | _ = a; | |
| 397 | _ = b; | |
| 398 | unreachable; | |
| 399 | } | |
| 400 | }; | |
| 401 | _ = E; | |
| 370 | 402 | |
| 371 | 403 | const Test = struct { |
| 372 | 404 | fn test_fn_1(a: anytype, b: anytype) @TypeOf(c_printf("%d %s\n", a, b)) { |
test/behavior/type_info.zig+9| ... | ... | @@ -357,6 +357,15 @@ test "type info: function type info" { |
| 357 | 357 | } |
| 358 | 358 | |
| 359 | 359 | fn testFunction() !void { |
| 360 | const S = struct { | |
| 361 | export fn typeInfoFoo() callconv(.c) usize { | |
| 362 | unreachable; | |
| 363 | } | |
| 364 | export fn typeInfoFooAligned() callconv(.c) usize { | |
| 365 | unreachable; | |
| 366 | } | |
| 367 | }; | |
| 368 | _ = S; | |
| 360 | 369 | const foo_fn_type = @TypeOf(typeInfoFoo); |
| 361 | 370 | const foo_fn_info = @typeInfo(foo_fn_type); |
| 362 | 371 | try expect(foo_fn_info.@"fn".calling_convention.eql(.c)); |