diff --git a/test/stage2/compare_output.zig b/test/stage2/compare_output.zig index 6c4b9c47e0..3e08394b2e 100644 --- a/test/stage2/compare_output.zig +++ b/test/stage2/compare_output.zig @@ -23,6 +23,12 @@ pub fn addCases(ctx: *TestContext) !void { case.addError("", &[_][]const u8{":1:1: error: no entry point found"}); + // Incorrect return type + case.addError( + \\export fn _start() noreturn { + \\} + , &[_][]const u8{":2:1: error: expected noreturn, found void"}); + // Regular old hello world case.addCompareOutput( \\export fn _start() noreturn { @@ -702,4 +708,16 @@ pub fn addCases(ctx: *TestContext) !void { "1109917696\n", ); } + + ctx.compileError("function redefinition", linux_x64, + \\fn entry() void {} + \\fn entry() void {} + , &[_][]const u8{":2:4: error: redefinition of 'entry'"}); + + ctx.compileError("extern variable has no type", linux_x64, + \\comptime { + \\ _ = foo; + \\} + \\extern var foo; + , &[_][]const u8{":4:1: error: unable to infer variable type"}); } diff --git a/test/stage2/compile_errors.zig b/test/stage2/compile_errors.zig index d90c0c7fae..ce53884aca 100644 --- a/test/stage2/compile_errors.zig +++ b/test/stage2/compile_errors.zig @@ -61,63 +61,4 @@ pub fn addCases(ctx: *TestContext) !void { \\@0 = str("_start") \\@1 = export(@0, "start") ); - - ctx.compileError("function redefinition", linux_x64, - \\fn entry() void {} - \\fn entry() void {} - , &[_][]const u8{":2:4: error: redefinition of 'entry'"}); - - ctx.compileError("incorrect return type", linux_x64, - \\export fn _start() noreturn { - \\} - , &[_][]const u8{":2:1: error: expected noreturn, found void"}); - - ctx.compileError("extern variable has no type", linux_x64, - \\comptime { - \\ _ = foo; - \\} - \\extern var foo; - , &[_][]const u8{":4:1: error: unable to infer variable type"}); - - //ctx.incrementalFailure("function redefinition", linux_x64, - // \\fn entry() void {} - // \\fn entry() void {} - //, &[_][]const u8{":2:4: error: redefinition of 'entry'"}, - // \\fn entry() void {} - //); - - //// TODO: need to make sure this works with other variants of export. - //ctx.incrementalFailure("exported symbol collision", linux_x64, - // \\export fn entry() void {} - // \\export fn entry() void {} - //, &[_][]const u8{":2:11: error: redefinition of 'entry'"}, - // \\export fn entry() void {} - //); - - // ctx.incrementalFailure("missing function name", linux_x64, - // \\fn() void {} - // , &[_][]const u8{":1:3: error: missing function name"}, - // \\fn a() void {} - // ); - - // TODO: re-enable these tests. - // https://github.com/ziglang/zig/issues/1364 - - //ctx.testCompileError( - // \\comptime { - // \\ return; - // \\} - //, "1.zig", 2, 5, "return expression outside function definition"); - - //ctx.testCompileError( - // \\export fn entry() void { - // \\ defer return; - // \\} - //, "1.zig", 2, 11, "cannot return from defer expression"); - - //ctx.testCompileError( - // \\export fn entry() c_int { - // \\ return 36893488147419103232; - // \\} - //, "1.zig", 2, 12, "integer value '36893488147419103232' cannot be stored in type 'c_int'"); }