diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2017-04-22 12:54:00 -0400 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2017-04-22 12:54:00 -0400 |
| commit | ad9040443cc35b7c250015a272a121a93244db31 (patch) | |
| tree | d5fab07bcb2c186ff8f207f51b700261fa4ab9d0 /test/compile_errors.zig | |
| parent | aafb0b90822e55135e1c50962768e54e6c62b164 (diff) | |
| download | zig-ad9040443cc35b7c250015a272a121a93244db31.tar.gz zig-ad9040443cc35b7c250015a272a121a93244db31.zip | |
new compile errors for setGlobalAlign and setGlobalSection builtins
if you try to use them on an external variable or function
then you get a compile error, since the alignment/section
is set externally in this case.
closes #244
Diffstat (limited to 'test/compile_errors.zig')
| -rw-r--r-- | test/compile_errors.zig | 44 |
1 files changed, 40 insertions, 4 deletions
diff --git a/test/compile_errors.zig b/test/compile_errors.zig index 5d6a456c38..568974fec5 100644 --- a/test/compile_errors.zig +++ b/test/compile_errors.zig @@ -1267,12 +1267,12 @@ pub fn addCases(cases: &tests.CompileErrorContext) { , ".tmp_source.zig:2:24: error: integer value 753664 cannot be implicitly casted to type 'u16'"); cases.add("set global variable alignment to non power of 2", - \\const some_data: [100]u8 = { + \\const some_data: [100]u8 = undefined; + \\comptime { \\ @setGlobalAlign(some_data, 3); - \\ undefined - \\}; + \\} \\export fn entry() -> usize { @sizeOf(@typeOf(some_data)) } - , ".tmp_source.zig:2:32: error: alignment value must be power of 2"); + , ".tmp_source.zig:3:32: error: alignment value must be power of 2"); cases.add("compile log", \\export fn foo() { @@ -1536,4 +1536,40 @@ pub fn addCases(cases: &tests.CompileErrorContext) { , "error: 'main' is private", ".tmp_source.zig:1:1: note: declared here"); + + cases.add("@setGlobalAlign extern variable", + \\extern var foo: i32; + \\comptime { + \\ @setGlobalAlign(foo, 4); + \\} + , + ".tmp_source.zig:3:5: error: cannot set alignment of external variable 'foo'", + ".tmp_source.zig:1:8: note: declared here"); + + cases.add("@setGlobalAlign extern fn", + \\extern fn foo(); + \\comptime { + \\ @setGlobalAlign(foo, 4); + \\} + , + ".tmp_source.zig:3:5: error: cannot set alignment of external function 'foo'", + ".tmp_source.zig:1:8: note: declared here"); + + cases.add("@setGlobalSection extern variable", + \\extern var foo: i32; + \\comptime { + \\ @setGlobalSection(foo, ".text2"); + \\} + , + ".tmp_source.zig:3:5: error: cannot set section of external variable 'foo'", + ".tmp_source.zig:1:8: note: declared here"); + + cases.add("@setGlobalSection extern fn", + \\extern fn foo(); + \\comptime { + \\ @setGlobalSection(foo, ".text2"); + \\} + , + ".tmp_source.zig:3:5: error: cannot set section of external function 'foo'", + ".tmp_source.zig:1:8: note: declared here"); } |
