aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJacob G-W <jacoblevgw@gmail.com>2021-06-22 12:04:19 -0400
committerAndrew Kelley <andrew@ziglang.org>2021-07-08 14:33:01 -0400
commitec36ac8b21fa6c6d8514c60555aba8a96490a560 (patch)
tree2a289989d4f8573eca918e32b8cbe2ffdcc0c8dc /test
parente2b954c2738c683a85b864eb33530f0e3dbbc480 (diff)
downloadzig-ec36ac8b21fa6c6d8514c60555aba8a96490a560.tar.gz
zig-ec36ac8b21fa6c6d8514c60555aba8a96490a560.zip
stage2 astgen: provide 3 more errors for invalid inline assembly
Diffstat (limited to 'test')
-rw-r--r--test/behavior/syntax.zig3
-rw-r--r--test/cases.zig33
2 files changed, 34 insertions, 2 deletions
diff --git a/test/behavior/syntax.zig b/test/behavior/syntax.zig
index 6f75810f38..c5f9fc70b1 100644
--- a/test/behavior/syntax.zig
+++ b/test/behavior/syntax.zig
@@ -60,8 +60,7 @@ fn asm_lists() void {
:[a] "x" (x),);
asm ("not real assembly"
:[a] "x" (->i32),:[a] "x" (1),);
- asm ("still not real assembly"
+ asm volatile ("still not real assembly"
:::"a","b",);
}
}
-
diff --git a/test/cases.zig b/test/cases.zig
index cc0b924bb3..37683072a2 100644
--- a/test/cases.zig
+++ b/test/cases.zig
@@ -1506,6 +1506,39 @@ pub fn addCases(ctx: *TestContext) !void {
\\ _ = x;
\\}
, &[_][]const u8{":4:27: error: expected type, found comptime_int"});
+ case.addError(
+ \\const S = struct {
+ \\ comptime {
+ \\ asm volatile (
+ \\ \\zig_moment:
+ \\ \\syscall
+ \\ );
+ \\ }
+ \\};
+ \\pub fn main() void {
+ \\ _ = S;
+ \\}
+ , &.{":3:13: error: volatile is meaningless on global assembly"});
+ case.addError(
+ \\pub fn main() void {
+ \\ var bruh: u32 = 1;
+ \\ asm (""
+ \\ :
+ \\ : [bruh] "{rax}" (4)
+ \\ : "memory"
+ \\ );
+ \\}
+ , &.{":3:5: error: assembly expression with no output must be marked volatile"});
+ case.addError(
+ \\pub fn main() void {}
+ \\comptime {
+ \\ asm (""
+ \\ :
+ \\ : [bruh] "{rax}" (4)
+ \\ : "memory"
+ \\ );
+ \\}
+ , &.{":3:5: error: global assembly cannot have inputs, outputs, or clobbers"});
}
{
var case = ctx.exe("comptime var", linux_x64);