New @export() handling

Use a struct as second parameter to be future proof (and also allows to
specify default values for the parameters)

Closes #2679 as it was just a matter of a few lines of code.
This commit is contained in:
LemonBoy
2020-01-09 10:36:51 +01:00
committed by Andrew Kelley
parent 4613e4d15f
commit 5ab5de89c0
13 changed files with 314 additions and 277 deletions

View File

@@ -5650,10 +5650,10 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
cases.add("wrong types given to @export",
\\fn entry() callconv(.C) void { }
\\comptime {
\\ @export("entry", entry, @as(u32, 1234));
\\ @export(entry, .{.name = "entry", .linkage = @as(u32, 1234) });
\\}
, &[_][]const u8{
"tmp.zig:3:29: error: expected type 'std.builtin.GlobalLinkage', found 'u32'",
"tmp.zig:3:50: error: expected type 'std.builtin.GlobalLinkage', found 'u32'",
});
cases.add("struct with invalid field",