Skip to content

Commit

Permalink
Sema: fix error notes with wrong extern type
Browse files Browse the repository at this point in the history
  • Loading branch information
wrongnull authored Nov 5, 2023
1 parent 3364454 commit e9a6197
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Sema.zig
Original file line number Diff line number Diff line change
Expand Up @@ -25573,7 +25573,7 @@ fn explainWhyTypeIsNotExtern(
try mod.errNoteNonLazy(src_loc, msg, "pointer to comptime-only type '{}'", .{pointee_ty.fmt(sema.mod)});
try sema.explainWhyTypeIsComptime(msg, src_loc, ty);
}
try sema.explainWhyTypeIsNotExtern(msg, src_loc, pointee_ty, position);
try sema.explainWhyTypeIsNotExtern(msg, src_loc, pointee_ty, .other);
}
},
.Void => try mod.errNoteNonLazy(src_loc, msg, "'void' is a zero bit type; for C 'void' use 'anyopaque'", .{}),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const Foo = extern struct {
f: *const fn() void,
};

pub fn entry() void {
_ = (Foo{}).f;
}

// error
// backend=stage2
// target=native
//
// :2:8: error: extern structs cannot contain fields of type '*const fn () void'
// :2:8: note: extern function must specify calling convention

0 comments on commit e9a6197

Please sign in to comment.