forked from ziglang/zig
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Sema: disallow using stage1 fn ptrs in extern contexts
Closes ziglang#13022
- Loading branch information
Showing
2 changed files
with
46 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
test/cases/compile_errors/old_fn_ptr_in_extern_context.zig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
const S = extern struct { | ||
a: fn () callconv(.C) void, | ||
}; | ||
comptime { | ||
_ = @sizeOf(S) == 1; | ||
} | ||
comptime { | ||
_ = [*c][4]fn() callconv(.C) void; | ||
} | ||
|
||
// error | ||
// backend=stage2 | ||
// target=native | ||
// | ||
// :2:5: error: extern structs cannot contain fields of type 'fn() callconv(.C) void' | ||
// :2:5: note: type has no guaranteed in-memory representation | ||
// :2:5: note: use '*const ' to make a function pointer type | ||
// :8:13: error: C pointers cannot point to non-C-ABI-compatible type '[4]fn() callconv(.C) void' | ||
// :8:13: note: type has no guaranteed in-memory representation | ||
// :8:13: note: use '*const ' to make a function pointer type |