mirror of
https://github.com/ziglang/zig.git
synced 2026-02-14 13:30:45 +00:00
CBE: support unreachable on GCC
This commit is contained in:
parent
d3eec7d46b
commit
78fe86dcd2
@ -8,3 +8,8 @@
|
||||
#define zig_noreturn
|
||||
#endif
|
||||
|
||||
#if __GNUC__
|
||||
#define zig_unreachable() __builtin_unreachable()
|
||||
#else
|
||||
#define zig_unreachable()
|
||||
#endif
|
||||
|
||||
@ -178,7 +178,7 @@ fn genBreak(file: *C, inst: *Inst.NoOp, decl: *Decl) !void {
|
||||
}
|
||||
|
||||
fn genUnreach(file: *C, inst: *Inst.NoOp, decl: *Decl) !void {
|
||||
// TODO ??
|
||||
try file.main.writer().writeAll(" zig_unreachable();\n");
|
||||
}
|
||||
|
||||
fn genAsm(file: *C, as: *Inst.Assembly, decl: *Decl, argdex: *usize) !void {
|
||||
|
||||
@ -65,7 +65,7 @@ pub fn addCases(ctx: *TestContext) !void {
|
||||
\\}
|
||||
\\
|
||||
);
|
||||
ctx.c("exit", linux_x64,
|
||||
ctx.c("exit with parameter", linux_x64,
|
||||
\\export fn _start() noreturn {
|
||||
\\ exit(0);
|
||||
\\}
|
||||
@ -96,6 +96,7 @@ pub fn addCases(ctx: *TestContext) !void {
|
||||
\\ register size_t rax_constant __asm__("rax") = 231;
|
||||
\\ register size_t rdi_constant __asm__("rdi") = arg0;
|
||||
\\ __asm volatile ("syscall" :: ""(rax_constant), ""(rdi_constant));
|
||||
\\ zig_unreachable();
|
||||
\\}
|
||||
\\
|
||||
);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user