aboutsummaryrefslogtreecommitdiff
path: root/test/compile_errors.zig
diff options
context:
space:
mode:
authorSahnvour <Sahnvour@users.noreply.github.com>2018-11-19 22:22:21 +0100
committerAndrew Kelley <superjoe30@gmail.com>2018-11-19 16:22:21 -0500
commit703c6684d103f14193411b589eaa0e0b1e1189f0 (patch)
tree3c19fddb4174bb5ed104e6dbac573533821956cd /test/compile_errors.zig
parent89e82281be73701f5a634770366e9dca5a0e89a9 (diff)
downloadzig-703c6684d103f14193411b589eaa0e0b1e1189f0.tar.gz
zig-703c6684d103f14193411b589eaa0e0b1e1189f0.zip
Crash fixes and small improvements to inline asm. (#1756)
* codegen: LLVMConstInlineAsm is deprecated. * codegen: replace commas in asm constraint strings by pipes as required by LLVM. * ir: enforce usage of '=' constraint modifier for inline assembly outputs. Others are not currently supported and this was just asserted alter in `ir_render_asm`. * asm: forbid comptime_int/floats as inputs in favor of explicitely sized constants. Fixes a crash due to comptime_int/floats having no type_ref. * asm: handle inputs with integers of <8 or non power of 2 bitsize. We widen them to the next highest power of two.
Diffstat (limited to 'test/compile_errors.zig')
-rw-r--r--test/compile_errors.zig28
1 files changed, 28 insertions, 0 deletions
diff --git a/test/compile_errors.zig b/test/compile_errors.zig
index 16690daf29..c5575a0c0b 100644
--- a/test/compile_errors.zig
+++ b/test/compile_errors.zig
@@ -5232,4 +5232,32 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
,
".tmp_source.zig:3:36: error: @ArgType could not resolve the type of arg 0 because 'fn(var)var' is generic",
);
+
+ cases.add(
+ "unsupported modifier at start of asm output constraint",
+ \\export fn foo() void {
+ \\ var bar: u32 = 3;
+ \\ asm volatile ("" : [baz]"+r"(bar) : : "");
+ \\}
+ ,
+ ".tmp_source.zig:3:5: error: invalid modifier starting output constraint for 'baz': '+', only '=' is supported. Compiler TODO: see https://github.com/ziglang/zig/issues/215",
+ );
+
+ cases.add(
+ "comptime_int in asm input",
+ \\export fn foo() void {
+ \\ asm volatile ("" : : [bar]"r"(3) : "");
+ \\}
+ ,
+ ".tmp_source.zig:2:35: error: expected sized integer or sized float, found comptime_int",
+ );
+
+ cases.add(
+ "comptime_float in asm input",
+ \\export fn foo() void {
+ \\ asm volatile ("" : : [bar]"r"(3.17) : "");
+ \\}
+ ,
+ ".tmp_source.zig:2:35: error: expected sized integer or sized float, found comptime_float",
+ );
}