authorgravatar for jacoblevgw@gmail.comJacob G-W <jacoblevgw@gmail.com> 2021-03-31 20:16:32-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-03-31 18:09:45-07:00
logfedc9ebd26175bf8309d665f3e1ee6769e8af86d
treec072a70aee3ef73ee368fc8f01baf3b407577924
parent3cebaaad1ca16a9e0203ed8c1684d0ce72da9487

stage2: cbe: restore all previously passing tests!


2 files changed, 96 insertions(+), 92 deletions(-)

src/Sema.zig+6-2
...@@ -3737,8 +3737,12 @@ fn analyzeRet(...@@ -3737,8 +3737,12 @@ fn analyzeRet(
3737 if (need_coercion) {3737 if (need_coercion) {
3738 if (sema.func) |func| {3738 if (sema.func) |func| {
3739 const fn_ty = func.owner_decl.typed_value.most_recent.typed_value.ty;3739 const fn_ty = func.owner_decl.typed_value.most_recent.typed_value.ty;
3740 const casted_operand = try sema.coerce(block, fn_ty.fnReturnType(), operand, src);3740 const fn_ret_ty = fn_ty.fnReturnType();
3741 _ = try block.addUnOp(src, Type.initTag(.noreturn), .ret, casted_operand);3741 const casted_operand = try sema.coerce(block, fn_ret_ty, operand, src);
3742 if (fn_ret_ty.zigTypeTag() == .Void)
3743 _ = try block.addNoOp(src, Type.initTag(.noreturn), .retvoid)
3744 else
3745 _ = try block.addUnOp(src, Type.initTag(.noreturn), .ret, casted_operand);
3742 return always_noreturn;3746 return always_noreturn;
3743 }3747 }
3744 }3748 }
test/stage2/cbe.zig+90-90
...@@ -374,36 +374,36 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -374,36 +374,36 @@ pub fn addCases(ctx: *TestContext) !void {
374 // , "");374 // , "");
375 //}375 //}
376376
377 //{377 {
378 // var case = ctx.exeFromCompiledC("errors", .{});378 var case = ctx.exeFromCompiledC("errors", .{});
379 // case.addCompareOutput(379 case.addCompareOutput(
380 // \\export fn main() c_int {380 \\export fn main() c_int {
381 // \\ var e1 = error.Foo;381 \\ var e1 = error.Foo;
382 // \\ var e2 = error.Bar;382 \\ var e2 = error.Bar;
383 // \\ assert(e1 != e2);383 \\ assert(e1 != e2);
384 // \\ assert(e1 == error.Foo);384 \\ assert(e1 == error.Foo);
385 // \\ assert(e2 == error.Bar);385 \\ assert(e2 == error.Bar);
386 // \\ return 0;386 \\ return 0;
387 // \\}387 \\}
388 // \\fn assert(b: bool) void {388 \\fn assert(b: bool) void {
389 // \\ if (!b) unreachable;389 \\ if (!b) unreachable;
390 // \\}390 \\}
391 // , "");391 , "");
392 // case.addCompareOutput(392 case.addCompareOutput(
393 // \\export fn main() c_int {393 \\export fn main() c_int {
394 // \\ var e: anyerror!c_int = 0;394 \\ var e: anyerror!c_int = 0;
395 // \\ const i = e catch 69;395 \\ const i = e catch 69;
396 // \\ return i;396 \\ return i;
397 // \\}397 \\}
398 // , "");398 , "");
399 // case.addCompareOutput(399 case.addCompareOutput(
400 // \\export fn main() c_int {400 \\export fn main() c_int {
401 // \\ var e: anyerror!c_int = error.Foo;401 \\ var e: anyerror!c_int = error.Foo;
402 // \\ const i = e catch 69;402 \\ const i = e catch 69;
403 // \\ return 69 - i;403 \\ return 69 - i;
404 // \\}404 \\}
405 // , "");405 , "");
406 //}406 }
407 ctx.c("empty start function", linux_x64,407 ctx.c("empty start function", linux_x64,
408 \\export fn _start() noreturn {408 \\export fn _start() noreturn {
409 \\ unreachable;409 \\ unreachable;
...@@ -417,64 +417,64 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -417,64 +417,64 @@ pub fn addCases(ctx: *TestContext) !void {
417 \\}417 \\}
418 \\418 \\
419 );419 );
420 //ctx.h("simple header", linux_x64,420 ctx.h("simple header", linux_x64,
421 // \\export fn start() void{}421 \\export fn start() void{}
422 //,422 ,
423 // \\ZIG_EXTERN_C void start(void);423 \\ZIG_EXTERN_C void start(void);
424 // \\424 \\
425 //);425 );
426 //ctx.h("header with single param function", linux_x64,426 ctx.h("header with single param function", linux_x64,
427 // \\export fn start(a: u8) void{}427 \\export fn start(a: u8) void{}
428 //,428 ,
429 // \\ZIG_EXTERN_C void start(uint8_t a0);429 \\ZIG_EXTERN_C void start(uint8_t a0);
430 // \\430 \\
431 //);431 );
432 //ctx.h("header with multiple param function", linux_x64,432 ctx.h("header with multiple param function", linux_x64,
433 // \\export fn start(a: u8, b: u8, c: u8) void{}433 \\export fn start(a: u8, b: u8, c: u8) void{}
434 //,434 ,
435 // \\ZIG_EXTERN_C void start(uint8_t a0, uint8_t a1, uint8_t a2);435 \\ZIG_EXTERN_C void start(uint8_t a0, uint8_t a1, uint8_t a2);
436 // \\436 \\
437 //);437 );
438 //ctx.h("header with u32 param function", linux_x64,438 ctx.h("header with u32 param function", linux_x64,
439 // \\export fn start(a: u32) void{}439 \\export fn start(a: u32) void{}
440 //,440 ,
441 // \\ZIG_EXTERN_C void start(uint32_t a0);441 \\ZIG_EXTERN_C void start(uint32_t a0);
442 // \\442 \\
443 //);443 );
444 //ctx.h("header with usize param function", linux_x64,444 ctx.h("header with usize param function", linux_x64,
445 // \\export fn start(a: usize) void{}445 \\export fn start(a: usize) void{}
446 //,446 ,
447 // \\ZIG_EXTERN_C void start(uintptr_t a0);447 \\ZIG_EXTERN_C void start(uintptr_t a0);
448 // \\448 \\
449 //);449 );
450 //ctx.h("header with bool param function", linux_x64,450 ctx.h("header with bool param function", linux_x64,
451 // \\export fn start(a: bool) void{}451 \\export fn start(a: bool) void{}
452 //,452 ,
453 // \\ZIG_EXTERN_C void start(bool a0);453 \\ZIG_EXTERN_C void start(bool a0);
454 // \\454 \\
455 //);455 );
456 //ctx.h("header with noreturn function", linux_x64,456 ctx.h("header with noreturn function", linux_x64,
457 // \\export fn start() noreturn {457 \\export fn start() noreturn {
458 // \\ unreachable;458 \\ unreachable;
459 // \\}459 \\}
460 //,460 ,
461 // \\ZIG_EXTERN_C zig_noreturn void start(void);461 \\ZIG_EXTERN_C zig_noreturn void start(void);
462 // \\462 \\
463 //);463 );
464 //ctx.h("header with multiple functions", linux_x64,464 ctx.h("header with multiple functions", linux_x64,
465 // \\export fn a() void{}465 \\export fn a() void{}
466 // \\export fn b() void{}466 \\export fn b() void{}
467 // \\export fn c() void{}467 \\export fn c() void{}
468 //,468 ,
469 // \\ZIG_EXTERN_C void a(void);469 \\ZIG_EXTERN_C void a(void);
470 // \\ZIG_EXTERN_C void b(void);470 \\ZIG_EXTERN_C void b(void);
471 // \\ZIG_EXTERN_C void c(void);471 \\ZIG_EXTERN_C void c(void);
472 // \\472 \\
473 //);473 );
474 //ctx.h("header with multiple includes", linux_x64,474 ctx.h("header with multiple includes", linux_x64,
475 // \\export fn start(a: u32, b: usize) void{}475 \\export fn start(a: u32, b: usize) void{}
476 //,476 ,
477 // \\ZIG_EXTERN_C void start(uint32_t a0, uintptr_t a1);477 \\ZIG_EXTERN_C void start(uint32_t a0, uintptr_t a1);
478 // \\478 \\
479 //);479 );
480}480}