Skip to content

Commit

Permalink
Sema: disallow using stage1 fn ptrs in extern contexts
Browse files Browse the repository at this point in the history
  • Loading branch information
Vexu committed Oct 6, 2022
1 parent dbd1c9b commit fb95732
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions compile_errors/old_fn_ptr_in_extern_context.zig
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

0 comments on commit fb95732

Please sign in to comment.