test: move compile errors and incremental tests into common dir

This commit is contained in:
Jakub Konka
2022-05-04 23:51:16 +02:00
parent 9d79b740bc
commit 3624e1ef48
952 changed files with 2 additions and 15 deletions

View File

@@ -1,26 +0,0 @@
pub fn main() void {
foo(123);
}
fn foo(x: u64) void {
if (x > 42) {
print();
}
}
fn print() void {
asm volatile ("svc #0"
:
: [number] "{x8}" (64),
[arg1] "{x0}" (1),
[arg2] "{x1}" (@ptrToInt("Hello, World!\n")),
[arg3] "{x2}" ("Hello, World!\n".len),
: "memory", "cc"
);
}
// run
// target=aarch64-linux
//
// Hello, World!
//

View File

@@ -1,25 +0,0 @@
pub fn main() void {
foo(true);
}
fn foo(x: bool) void {
if (x) {
print();
}
}
fn print() void {
asm volatile ("svc #0"
:
: [number] "{x8}" (64),
[arg1] "{x0}" (1),
[arg2] "{x1}" (@ptrToInt("Hello, World!\n")),
[arg3] "{x2}" ("Hello, World!\n".len),
: "memory", "cc"
);
}
// run
//
// Hello, World!
//

View File

@@ -1,31 +0,0 @@
pub export fn _start() noreturn {
print();
exit(0);
}
fn print() void {
asm volatile ("svc #0"
:
: [number] "{x8}" (64),
[arg1] "{x0}" (1),
[arg2] "{x1}" (@ptrToInt("Hello, World!\n")),
[arg3] "{x2}" ("Hello, World!\n".len),
: "memory", "cc"
);
}
fn exit(ret: usize) noreturn {
asm volatile ("svc #0"
:
: [number] "{x8}" (93),
[arg1] "{x0}" (ret),
: "memory", "cc"
);
unreachable;
}
// run
// target=aarch64-linux
//
// Hello, World!
//

View File

@@ -1,36 +0,0 @@
pub export fn _start() noreturn {
print();
print();
print();
print();
exit(0);
}
fn print() void {
asm volatile ("svc #0"
:
: [number] "{x8}" (64),
[arg1] "{x0}" (1),
[arg2] "{x1}" (@ptrToInt("Hello, World!\n")),
[arg3] "{x2}" ("Hello, World!\n".len),
: "memory", "cc"
);
}
fn exit(ret: usize) noreturn {
asm volatile ("svc #0"
:
: [number] "{x8}" (93),
[arg1] "{x0}" (ret),
: "memory", "cc"
);
unreachable;
}
// run
//
// Hello, World!
// Hello, World!
// Hello, World!
// Hello, World!
//

View File

@@ -1,21 +0,0 @@
pub fn main() void {
print();
print();
}
fn print() void {
asm volatile ("svc #0"
:
: [number] "{x8}" (64),
[arg1] "{x0}" (1),
[arg2] "{x1}" (@ptrToInt("Hello, World!\n")),
[arg3] "{x2}" ("Hello, World!\n".len),
: "memory", "cc"
);
}
// run
//
// Hello, World!
// Hello, World!
//

View File

@@ -1,5 +0,0 @@
// error
// output_mode=Exe
// target=aarch64-macos
//
// :107:9: error: struct 'tmp.tmp' has no member named 'main'

View File

@@ -1,5 +0,0 @@
pub export fn main() noreturn {}
// error
//
// :1:32: error: expected noreturn, found void

View File

@@ -1,19 +0,0 @@
extern "c" fn write(usize, usize, usize) usize;
extern "c" fn exit(usize) noreturn;
pub export fn main() noreturn {
print();
exit(0);
}
fn print() void {
const msg = @ptrToInt("Hello, World!\n");
const len = 14;
_ = write(1, msg, len);
}
// run
//
// Hello, World!
//

View File

@@ -1,16 +0,0 @@
extern "c" fn write(usize, usize, usize) usize;
pub fn main() void {
print();
}
fn print() void {
const msg = @ptrToInt("Hello, World!\n");
const len = 14;
_ = write(1, msg, len);
}
// run
//
// Hello, World!
//

View File

@@ -1,22 +0,0 @@
extern "c" fn write(usize, usize, usize) usize;
pub fn main() void {
print();
print();
print();
print();
}
fn print() void {
const msg = @ptrToInt("Hello, World!\n");
const len = 14;
_ = write(1, msg, len);
}
// run
//
// Hello, World!
// Hello, World!
// Hello, World!
// Hello, World!
//

View File

@@ -1,16 +0,0 @@
extern "c" fn write(usize, usize, usize) usize;
pub fn main() void {
print();
}
fn print() void {
const msg = @ptrToInt("What is up? This is a longer message that will force the data to be relocated in virtual address space.\n");
const len = 104;
_ = write(1, msg, len);
}
// run
//
// What is up? This is a longer message that will force the data to be relocated in virtual address space.
//

View File

@@ -1,18 +0,0 @@
extern "c" fn write(usize, usize, usize) usize;
pub fn main() void {
print();
print();
}
fn print() void {
const msg = @ptrToInt("What is up? This is a longer message that will force the data to be relocated in virtual address space.\n");
const len = 104;
_ = write(1, msg, len);
}
// run
//
// What is up? This is a longer message that will force the data to be relocated in virtual address space.
// What is up? This is a longer message that will force the data to be relocated in virtual address space.
//

View File

@@ -1,10 +0,0 @@
pub fn main() void {
add(3, 4);
}
fn add(a: u32, b: u32) void {
if (a + b != 7) unreachable;
}
// run
//

View File

@@ -1,12 +0,0 @@
pub fn main() void {
if (x - 7 != 0) unreachable;
}
fn add(a: u32, b: u32) u32 {
return a + b;
}
const x = add(3, 4);
// run
//

View File

@@ -1,12 +0,0 @@
pub fn main() void {
var x: usize = 3;
const y = add(1, 2, x);
if (y - 6 != 0) unreachable;
}
inline fn add(a: usize, b: usize, c: usize) usize {
return a + b + c;
}
// run
//

View File

@@ -1,13 +0,0 @@
const T = struct {
const T = struct {
fn f() void {
_ = T;
}
};
};
// error
//
// :4:17: error: ambiguous reference
// :2:5: note: declared here
// :1:1: note: also declared here

View File

@@ -1,21 +0,0 @@
pub fn main() void {
print(2, 4);
print(1, 7);
}
fn print(a: u32, b: u32) void {
asm volatile ("svc #0"
:
: [number] "{r7}" (4),
[arg3] "{r2}" (a + b),
[arg1] "{r0}" (1),
[arg2] "{r1}" (@ptrToInt("123456789")),
: "memory"
);
return;
}
// run
// target=arm-linux
//
// 12345612345678

View File

@@ -1,20 +0,0 @@
pub fn main() void {
print(10, 5);
print(4, 3);
}
fn print(a: u32, b: u32) void {
asm volatile ("svc #0"
:
: [number] "{r7}" (4),
[arg3] "{r2}" (a - b),
[arg1] "{r0}" (1),
[arg2] "{r1}" (@ptrToInt("123456789")),
: "memory"
);
return;
}
// run
//
// 123451

View File

@@ -1,20 +0,0 @@
pub fn main() void {
print(8, 9);
print(3, 7);
}
fn print(a: u32, b: u32) void {
asm volatile ("svc #0"
:
: [number] "{r7}" (4),
[arg3] "{r2}" (a & b),
[arg1] "{r0}" (1),
[arg2] "{r1}" (@ptrToInt("123456789")),
: "memory"
);
return;
}
// run
//
// 12345678123

View File

@@ -1,20 +0,0 @@
pub fn main() void {
print(4, 2);
print(3, 7);
}
fn print(a: u32, b: u32) void {
asm volatile ("svc #0"
:
: [number] "{r7}" (4),
[arg3] "{r2}" (a | b),
[arg1] "{r0}" (1),
[arg2] "{r1}" (@ptrToInt("123456789")),
: "memory"
);
return;
}
// run
//
// 1234561234567

View File

@@ -1,20 +0,0 @@
pub fn main() void {
print(42, 42);
print(3, 5);
}
fn print(a: u32, b: u32) void {
asm volatile ("svc #0"
:
: [number] "{r7}" (4),
[arg3] "{r2}" (a ^ b),
[arg1] "{r0}" (1),
[arg2] "{r1}" (@ptrToInt("123456789")),
: "memory"
);
return;
}
// run
//
// 123456

View File

@@ -1,15 +0,0 @@
pub fn main() void {
var x: u32 = 1;
assert(x << 1 == 2);
x <<= 1;
assert(x << 2 == 8);
assert(x << 3 == 16);
}
pub fn assert(ok: bool) void {
if (!ok) unreachable; // assertion failure
}
// run
//

View File

@@ -1,21 +0,0 @@
pub fn main() void {
var a: u32 = 1024;
assert(a >> 1 == 512);
a >>= 1;
assert(a >> 2 == 128);
assert(a >> 3 == 64);
assert(a >> 4 == 32);
assert(a >> 5 == 16);
assert(a >> 6 == 8);
assert(a >> 7 == 4);
assert(a >> 8 == 2);
assert(a >> 9 == 1);
}
pub fn assert(ok: bool) void {
if (!ok) unreachable; // assertion failure
}
// run
//

View File

@@ -1,21 +0,0 @@
pub fn main() void {
foo() catch print();
}
fn foo() anyerror!void {}
fn print() void {
asm volatile ("svc #0"
:
: [number] "{r7}" (4),
[arg1] "{r0}" (1),
[arg2] "{r1}" (@ptrToInt("Hello, World!\n")),
[arg3] "{r2}" ("Hello, World!\n".len),
: "memory"
);
return;
}
// run
// target=arm-linux
//

View File

@@ -1,24 +0,0 @@
pub fn main() void {
foo() catch print();
}
fn foo() anyerror!void {
return error.Test;
}
fn print() void {
asm volatile ("svc #0"
:
: [number] "{r7}" (4),
[arg1] "{r0}" (1),
[arg2] "{r1}" (@ptrToInt("Hello, World!\n")),
[arg3] "{r2}" ("Hello, World!\n".len),
: "memory"
);
return;
}
// run
//
// Hello, World!
//

View File

@@ -1,27 +0,0 @@
pub fn main() void {
foo() catch |err| {
assert(err == error.Foo);
assert(err != error.Bar);
assert(err != error.Baz);
};
bar() catch |err| {
assert(err != error.Foo);
assert(err == error.Bar);
assert(err != error.Baz);
};
}
fn assert(ok: bool) void {
if (!ok) unreachable;
}
fn foo() anyerror!void {
return error.Foo;
}
fn bar() anyerror!void {
return error.Bar;
}
// run
//

View File

@@ -1,12 +0,0 @@
pub fn main() void {
foo() catch unreachable;
}
fn foo() anyerror!void {
try bar();
}
fn bar() anyerror!void {}
// run
//

View File

@@ -1,44 +0,0 @@
const PrintFn = *const fn () void;
pub fn main() void {
var printFn: PrintFn = stopSayingThat;
var i: u32 = 0;
while (i < 4) : (i += 1) printFn();
printFn = moveEveryZig;
printFn();
}
fn stopSayingThat() void {
asm volatile ("svc #0"
:
: [number] "{r7}" (4),
[arg1] "{r0}" (1),
[arg2] "{r1}" (@ptrToInt("Hello, my name is Inigo Montoya; you killed my father, prepare to die.\n")),
[arg3] "{r2}" ("Hello, my name is Inigo Montoya; you killed my father, prepare to die.\n".len),
: "memory"
);
return;
}
fn moveEveryZig() void {
asm volatile ("svc #0"
:
: [number] "{r7}" (4),
[arg1] "{r0}" (1),
[arg2] "{r1}" (@ptrToInt("All your codebase are belong to us\n")),
[arg3] "{r2}" ("All your codebase are belong to us\n".len),
: "memory"
);
return;
}
// run
// target=arm-linux
//
// Hello, my name is Inigo Montoya; you killed my father, prepare to die.
// Hello, my name is Inigo Montoya; you killed my father, prepare to die.
// Hello, my name is Inigo Montoya; you killed my father, prepare to die.
// Hello, my name is Inigo Montoya; you killed my father, prepare to die.
// All your codebase are belong to us
//

View File

@@ -1,32 +0,0 @@
pub export fn _start() noreturn {
print();
exit();
}
fn print() void {
asm volatile ("svc #0"
:
: [number] "{r7}" (4),
[arg1] "{r0}" (1),
[arg2] "{r1}" (@ptrToInt("Hello, World!\n")),
[arg3] "{r2}" (14),
: "memory"
);
return;
}
fn exit() noreturn {
asm volatile ("svc #0"
:
: [number] "{r7}" (1),
[arg1] "{r0}" (0),
: "memory"
);
unreachable;
}
// run
// target=arm-linux
//
// Hello, World!
//

View File

@@ -1,37 +0,0 @@
pub export fn _start() noreturn {
print();
print();
print();
print();
exit();
}
fn print() void {
asm volatile ("svc #0"
:
: [number] "{r7}" (4),
[arg1] "{r0}" (1),
[arg2] "{r1}" (@ptrToInt("Hello, World!\n")),
[arg3] "{r2}" (14),
: "memory"
);
return;
}
fn exit() noreturn {
asm volatile ("svc #0"
:
: [number] "{r7}" (1),
[arg1] "{r0}" (0),
: "memory"
);
unreachable;
}
// run
//
// Hello, World!
// Hello, World!
// Hello, World!
// Hello, World!
//

View File

@@ -1,22 +0,0 @@
pub fn main() void {
print();
print();
}
fn print() void {
asm volatile ("svc #0"
:
: [number] "{r7}" (4),
[arg1] "{r0}" (1),
[arg2] "{r1}" (@ptrToInt("Hello, World!\n")),
[arg3] "{r2}" (14),
: "memory"
);
return;
}
// run
//
// Hello, World!
// Hello, World!
//

View File

@@ -1,28 +0,0 @@
pub fn main() void {
print(id(14));
}
fn id(x: u32) u32 {
return x;
}
// TODO: The parameters to the asm statement in print() had to
// be in a specific order because otherwise the write to r0
// would overwrite the len parameter which resides in r0
fn print(len: u32) void {
asm volatile ("svc #0"
:
: [number] "{r7}" (4),
[arg3] "{r2}" (len),
[arg1] "{r0}" (1),
[arg2] "{r1}" (@ptrToInt("Hello, World!\n")),
: "memory"
);
return;
}
// run
// target=arm-linux
//
// Hello, World!
//

View File

@@ -1,14 +0,0 @@
pub fn main() void {
assert(add(1, 2, 3, 4, 5, 6) == 21);
}
fn add(a: u32, b: u32, c: u32, d: u32, e: u32, f: u32) u32 {
return a + b + c + d + e + f;
}
pub fn assert(ok: bool) void {
if (!ok) unreachable; // assertion failure
}
// run
//

View File

@@ -1,40 +0,0 @@
pub fn main() void {
printNumberHex(0x00000000);
printNumberHex(0xaaaaaaaa);
printNumberHex(0xdeadbeef);
printNumberHex(0x31415926);
}
fn printNumberHex(x: u32) void {
var i: u5 = 28;
while (true) : (i -= 4) {
const digit = (x >> i) & 0xf;
asm volatile ("svc #0"
:
: [number] "{r7}" (4),
[arg1] "{r0}" (1),
[arg2] "{r1}" (@ptrToInt("0123456789abcdef") + digit),
[arg3] "{r2}" (1),
: "memory"
);
if (i == 0) break;
}
asm volatile ("svc #0"
:
: [number] "{r7}" (4),
[arg1] "{r0}" (1),
[arg2] "{r1}" (@ptrToInt("\n")),
[arg3] "{r2}" (1),
: "memory"
);
}
// run
// target=arm-linux
//
// 00000000
// aaaaaaaa
// deadbeef
// 31415926
//

View File

@@ -1,38 +0,0 @@
pub fn main() void {
assert(add(3, 4) == 791);
}
fn add(a: u32, b: u32) u32 {
const x: u32 = blk: {
const c = a + b; // 7
const d = a + c; // 10
const e = d + b; // 14
const f = d + e; // 24
const g = e + f; // 38
const h = f + g; // 62
const i = g + h; // 100
const j = i + d; // 110
const k = i + j; // 210
const l = k + c; // 217
const m = l + d; // 227
const n = m + e; // 241
const o = n + f; // 265
const p = o + g; // 303
const q = p + h; // 365
const r = q + i; // 465
const s = r + j; // 575
const t = s + k; // 785
break :blk t;
};
const y = x + a; // 788
const z = y + a; // 791
return z;
}
fn assert(ok: bool) void {
if (!ok) unreachable;
}
// run
// target=arm-linux
//

View File

@@ -1,37 +0,0 @@
pub fn main() void {
assert(addMul(3, 4) == 357747496);
}
fn addMul(a: u32, b: u32) u32 {
const x: u32 = blk: {
const c = a + b; // 7
const d = a + c; // 10
const e = d + b; // 14
const f = d + e; // 24
const g = e + f; // 38
const h = f + g; // 62
const i = g + h; // 100
const j = i + d; // 110
const k = i + j; // 210
const l = k + c; // 217
const m = l * d; // 2170
const n = m + e; // 2184
const o = n * f; // 52416
const p = o + g; // 52454
const q = p * h; // 3252148
const r = q + i; // 3252248
const s = r * j; // 357747280
const t = s + k; // 357747490
break :blk t;
};
const y = x + a; // 357747493
const z = y + a; // 357747496
return z;
}
fn assert(ok: bool) void {
if (!ok) unreachable;
}
// run
//

View File

@@ -1,9 +0,0 @@
pub fn main() void {
var x = null;
_ = x;
}
// error
// output_mode=Exe
//
// :2:9: error: variable of type '@TypeOf(null)' must be const or comptime

View File

@@ -1,9 +0,0 @@
pub fn main() void {
var i: u8 = 5;
i += 20;
if (i != 25) unreachable;
}
// run
// target=wasm32-wasi
//

View File

@@ -1,8 +0,0 @@
pub fn main() void {
var i: i32 = 2147483647;
if (i +% 1 != -2147483648) unreachable;
return;
}
// run
//

View File

@@ -1,13 +0,0 @@
pub fn main() void {
var i: u32 = 5;
i *= 7;
var result: u32 = foo(i, 10);
if (result != 350) unreachable;
return;
}
fn foo(x: u32, y: u32) u32 {
return x * y;
}
// run
//

View File

@@ -1,9 +0,0 @@
pub fn main() void {
var i: i32 = 2147483647;
const result = i *% 2;
if (result != -2) unreachable;
return;
}
// run
//

View File

@@ -1,8 +0,0 @@
pub fn main() void {
var i: u3 = 3;
if (i *% 3 != 1) unreachable;
return;
}
// run
//

View File

@@ -1,8 +0,0 @@
pub fn main() void {
var i: i4 = 3;
if (i *% 3 != 1) unreachable;
return;
}
// run
//

View File

@@ -1,13 +0,0 @@
pub fn main() void {
var i: u32 = 352;
i /= 7; // i = 50
var result: u32 = foo(i, 7);
if (result != 7) unreachable;
return;
}
fn foo(x: u32, y: u32) u32 {
return x / y;
}
// run
//

View File

@@ -1,8 +0,0 @@
pub fn main() u8 {
var i: u8 = 5;
i &= 6;
return i - 4;
}
// run
//

View File

@@ -1,8 +0,0 @@
pub fn main() u8 {
var i: u8 = 5;
i |= 6;
return i - 7;
}
// run
//

View File

@@ -1,8 +0,0 @@
pub fn main() u8 {
var i: u8 = 5;
i ^= 6;
return i - 3;
}
// run
//

View File

@@ -1,9 +0,0 @@
pub fn main() void {
var b: bool = false;
b = b or false;
if (b) unreachable;
return;
}
// run
//

View File

@@ -1,9 +0,0 @@
pub fn main() void {
var b: bool = true;
b = b or false;
if (!b) unreachable;
return;
}
// run
//

View File

@@ -1,8 +0,0 @@
pub fn main() void {
var i: i4 = 7;
if (i +% 1 != 0) unreachable;
return;
}
// run
//

View File

@@ -1,9 +0,0 @@
pub fn main() void {
var b: bool = false;
b = b or true;
if (!b) unreachable;
return;
}
// run
//

View File

@@ -1,9 +0,0 @@
pub fn main() void {
var b: bool = true;
b = b or true;
if (!b) unreachable;
return;
}
// run
//

View File

@@ -1,9 +0,0 @@
pub fn main() void {
var b: bool = false;
b = b and false;
if (b) unreachable;
return;
}
// run
//

View File

@@ -1,9 +0,0 @@
pub fn main() void {
var b: bool = true;
b = b and false;
if (b) unreachable;
return;
}
// run
//

View File

@@ -1,9 +0,0 @@
pub fn main() void {
var b: bool = false;
b = b and true;
if (b) unreachable;
return;
}
// run
//

View File

@@ -1,9 +0,0 @@
pub fn main() void {
var b: bool = true;
b = b and true;
if (!b) unreachable;
return;
}
// run
//

View File

@@ -1,7 +0,0 @@
pub fn main() u8 {
var i: u8 = 255;
return i +% 1;
}
// run
//

View File

@@ -1,12 +0,0 @@
pub fn main() u8 {
var i: u8 = 5;
i += 20;
var result: u8 = foo(i, 10);
return result - 35;
}
fn foo(x: u8, y: u8) u8 {
return x + y;
}
// run
//

View File

@@ -1,8 +0,0 @@
pub fn main() u8 {
var i: u8 = 20;
i -= 5;
return i - 15;
}
// run
//

View File

@@ -1,8 +0,0 @@
pub fn main() void {
var i: i32 = -2147483648;
if (i -% 1 != 2147483647) unreachable;
return;
}
// run
//

View File

@@ -1,8 +0,0 @@
pub fn main() void {
var i: i7 = -64;
if (i -% 1 != 63) unreachable;
return;
}
// run
//

View File

@@ -1,7 +0,0 @@
pub fn main() void {
var i: u4 = 0;
if (i -% 1 != 15) unreachable;
}
// run
//

View File

@@ -1,12 +0,0 @@
pub fn main() u8 {
var i: u8 = 5;
i -= 3;
var result: u8 = foo(i, 10);
return result - 8;
}
fn foo(x: u8, y: u8) u8 {
return y - x;
}
// run
//

View File

@@ -1,9 +0,0 @@
pub fn main() void {
while (true) {
break;
}
}
// run
// target=x86_64-linux,x86_64-macos,aarch64-linux,aarch64-macos
//

View File

@@ -1,8 +0,0 @@
pub fn main() void {
foo: while (true) {
break :foo;
}
}
// run
//

View File

@@ -1,10 +0,0 @@
pub fn main() void {
var i: u64 = 0;
while (true) : (i += 1) {
if (i == 4) return;
continue;
}
}
// run
//

View File

@@ -1,10 +0,0 @@
pub fn main() void {
var i: u64 = 0;
foo: while (true) : (i += 1) {
if (i == 4) return;
continue :foo;
}
}
// run
//

View File

@@ -1,11 +0,0 @@
pub fn main() void {
const i: anyerror!u64 = 0;
const caught = i catch 5;
assert(caught == 0);
}
fn assert(b: bool) void {
if (!b) unreachable;
}
// run
//

View File

@@ -1,11 +0,0 @@
pub fn main() void {
const i: anyerror!u64 = error.B;
const caught = i catch 5;
assert(caught == 5);
}
fn assert(b: bool) void {
if (!b) unreachable;
}
// run
//

View File

@@ -1,11 +0,0 @@
pub fn main() void {
const a: anyerror!comptime_int = 42;
const b: *const comptime_int = &(a catch unreachable);
assert(b.* == 42);
}
fn assert(b: bool) void {
if (!b) unreachable; // assertion failure
}
// run
//

View File

@@ -1,10 +0,0 @@
pub fn main() void {
const a: anyerror!u32 = error.B;
_ = &(a catch |err| assert(err == error.B));
}
fn assert(b: bool) void {
if (!b) unreachable;
}
// run
//

View File

@@ -1,10 +0,0 @@
pub fn main() void {
const a: anyerror!u32 = error.Bar;
a catch |err| assert(err == error.Bar);
}
fn assert(b: bool) void {
if (!b) unreachable;
}
// run
//

View File

@@ -1,7 +0,0 @@
export fn foo() void {
@compileError("this is an error");
}
// error
//
// :2:5: error: this is an error

View File

@@ -1,16 +0,0 @@
pub fn main() void {
var x: usize = 3;
const y = add(10, 2, x);
if (y - 6 != 0) unreachable;
}
inline fn add(a: usize, b: usize, c: usize) usize {
if (a == 10) @compileError("bad");
return a + b + c;
}
// error
// output_mode=Exe
//
// :8:18: error: bad
// :3:18: note: called from here

View File

@@ -1,13 +0,0 @@
pub fn main() void {
var x: usize = 3;
const y = add(1, 2, x);
if (y - 6 != 0) unreachable;
}
inline fn add(a: usize, b: usize, c: usize) usize {
if (a == 10) @compileError("bad");
return a + b + c;
}
// run
//

View File

@@ -1,17 +0,0 @@
export fn _start() noreturn {
const b = true;
var f: u32 = 1;
@compileLog(b, 20, f, x);
@compileLog(1000);
var bruh: usize = true;
_ = bruh;
unreachable;
}
export fn other() void {
@compileLog(1234);
}
fn x() void {}
// error
//
// :6:23: error: expected usize, found bool

View File

@@ -1,16 +0,0 @@
export fn _start() noreturn {
const b = true;
var f: u32 = 1;
@compileLog(b, 20, f, x);
@compileLog(1000);
unreachable;
}
export fn other() void {
@compileLog(1234);
}
fn x() void {}
// error
//
// :9:5: error: found compile log statement
// :4:5: note: also here

View File

@@ -1,6 +0,0 @@
pub const a = if (true && false) 1 else 2;
// error
// output_mode=Exe
//
// :1:24: error: ambiguous use of '&&'; use 'and' for logical AND, or change whitespace to ' & &' for bitwise AND

View File

@@ -1,11 +0,0 @@
pub fn main() void {
const a = true;
const b = false;
_ = a & &b;
}
// error
//
// :4:11: error: incompatible types: 'bool' and '*const bool'
// :4:9: note: type 'bool' here
// :4:13: note: type '*const bool' here

View File

@@ -1,7 +0,0 @@
pub fn main() void {
const b: u8 = 1;
_ = &&b;
}
// run
//

View File

@@ -1,18 +0,0 @@
const Number = enum { One, Two, Three };
pub fn main() void {
var number1 = Number.One;
var number2: Number = .Two;
if (false) {
number1;
number2;
}
const number3 = @intToEnum(Number, 2);
if (@enumToInt(number3) != 2) {
unreachable;
}
return;
}
// run
//

View File

@@ -1,22 +0,0 @@
const Number = enum { One, Two, Three };
pub fn main() void {
var number1 = Number.One;
var number2: Number = .Two;
const number3 = @intToEnum(Number, 2);
assert(number1 != number2);
assert(number2 != number3);
assert(@enumToInt(number1) == 0);
assert(@enumToInt(number2) == 1);
assert(@enumToInt(number3) == 2);
var x: Number = .Two;
assert(number2 == x);
return;
}
fn assert(val: bool) void {
if (!val) unreachable;
}
// run
//

View File

@@ -1,9 +0,0 @@
comptime {
const x = foo + foo;
_ = x;
}
extern var foo: i32;
// error
//
// :2:15: error: unable to resolve comptime value

View File

@@ -1,8 +0,0 @@
export fn entry() void {
_ = foo;
}
extern var foo;
// error
//
// :4:8: error: unable to infer variable type

View File

@@ -1,12 +0,0 @@
pub fn main() void {
foo();
bar();
}
fn foo() void {
bar();
bar();
}
fn bar() void {}
// run
//

View File

@@ -1,15 +0,0 @@
pub fn main() void {
bar();
foo();
foo();
bar();
foo();
bar();
}
fn foo() void {
bar();
}
fn bar() void {}
// run
//

View File

@@ -1,14 +0,0 @@
pub fn main() void {
bar();
foo();
return;
}
fn foo() void {
bar();
bar();
bar();
}
fn bar() void {}
// run
//

View File

@@ -1,10 +0,0 @@
pub fn main() void {
foo(10, 20);
}
fn foo(x: u8, y: u8) void {
_ = x;
_ = y;
}
// run
//

View File

@@ -1,14 +0,0 @@
// dummy comment
fn entry() void {}
fn entry() void {}
fn foo() void {
var foo = 1234;
}
// error
//
// :3:1: error: redeclaration of 'entry'
// :2:1: note: other declaration here
// :6:9: error: local shadows declaration of 'foo'
// :5:1: note: declared here

View File

@@ -1,8 +0,0 @@
// dummy comment
var foo = false;
var foo = true;
// error
//
// :3:1: error: redeclaration of 'foo'
// :2:1: note: other declaration here

View File

@@ -1,15 +0,0 @@
pub fn f() void {
var bar: bool = true;
const S = struct {
fn baz() bool {
return bar;
}
};
_ = S;
}
// error
//
// :5:20: error: mutable 'bar' not accessible from here
// :2:9: note: declared mutable here
// :3:15: note: crosses namespace boundary here

View File

@@ -1,8 +0,0 @@
pub fn main() void {
_ = @intToPtr(*u8, 0);
}
// error
// output_mode=Exe
//
// :2:24: error: pointer type '*u8' does not allow address zero

View File

@@ -1,7 +0,0 @@
pub fn main() void {
_ = @intToPtr(*u32, 2);
}
// error
//
// :2:25: error: pointer type '*u32' requires aligned address

View File

@@ -1,38 +0,0 @@
pub fn main() void {
assert(add(3, 4) == 791);
}
fn add(a: u32, b: u32) u32 {
const x: u32 = blk: {
const c = a + b; // 7
const d = a + c; // 10
const e = d + b; // 14
const f = d + e; // 24
const g = e + f; // 38
const h = f + g; // 62
const i = g + h; // 100
const j = i + d; // 110
const k = i + j; // 210
const l = k + c; // 217
const m = l + d; // 227
const n = m + e; // 241
const o = n + f; // 265
const p = o + g; // 303
const q = p + h; // 365
const r = q + i; // 465
const s = r + j; // 575
const t = s + k; // 785
break :blk t;
};
const y = x + a; // 788
const z = y + a; // 791
return z;
}
fn assert(ok: bool) void {
if (!ok) unreachable;
}
// run
// target=aarch64-linux,aarch64-macos
//

View File

@@ -1,12 +0,0 @@
fn entry(a: *addrspace(.gs) ?[1]i32) *addrspace(.gs) i32 {
return &a.*.?[0];
}
pub fn main() void {
_ = entry;
}
// error
// output_mode=Exe
// backend=llvm
// target=x86_64-linux,x86_64-macos
//

View File

@@ -1,12 +0,0 @@
fn entry(a: *addrspace(.gs) [1]i32) *addrspace(.gs) i32 {
return &a[0];
}
pub fn main() void {
_ = entry;
}
// error
// output_mode=Exe
// backend=stage2,llvm
// target=x86_64-linux,x86_64-macos
//

View File

@@ -1,13 +0,0 @@
const A = struct { a: ?[1]i32 };
fn entry(a: *addrspace(.gs) [1]A) *addrspace(.gs) i32 {
return &a[0].a.?[0];
}
pub fn main() void {
_ = entry;
}
// error
// output_mode=Exe
// backend=llvm
// target=x86_64-linux,x86_64-macos
//

View File

@@ -1,13 +0,0 @@
const A = struct { a: i32 };
fn entry(a: *addrspace(.gs) A) *addrspace(.gs) i32 {
return &a.a;
}
pub fn main() void {
_ = entry;
}
// error
// output_mode=Exe
// backend=stage2,llvm
// target=x86_64-linux,x86_64-macos
//

View File

@@ -1,11 +0,0 @@
pub fn main() void {
var a: ?*anyopaque = undefined;
a = @as(?usize, null);
}
// error
// output_mode=Exe
// backend=stage2,llvm
// target=x86_64-linux,x86_64-macos
//
// :3:21: error: expected *anyopaque, found ?usize

View File

@@ -1,22 +0,0 @@
fn assert(ok: bool) void {
if (!ok) unreachable;
}
fn foo(ok: bool) i32 {
const val: i32 = blk: {
var x: i32 = 1;
if (!ok) break :blk x + 9;
break :blk x + 19;
};
return val + 10;
}
pub fn main() void {
assert(foo(false) == 20);
assert(foo(true) == 30);
}
// run
// backend=stage2,llvm
// target=x86_64-linux,x86_64-macos
//

Some files were not shown because too many files have changed in this diff Show More