diff options
| author | Matthew Lugg <mlugg@mlugg.co.uk> | 2024-12-19 07:57:16 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-12-19 07:57:16 +0000 |
| commit | e2e3633612be656177512873a9de6524082d04dd (patch) | |
| tree | c71b592a592e21b108fccc0be3f99a45b6a13c6e /test/cases/compile_errors | |
| parent | f857bf72e2239718bbbe4cba08d6961ad77fc69a (diff) | |
| parent | 58b8b1ac2af642e886f3a561bf6dfd971bb80a96 (diff) | |
| download | zig-e2e3633612be656177512873a9de6524082d04dd.tar.gz zig-e2e3633612be656177512873a9de6524082d04dd.zip | |
Merge pull request #22264 from mlugg/no-generic-callconv
compiler: disallow `callconv` etc from depending on function parameters
Also, disallow `align`/`linksection`/`addrspace` annotations on container-level declarations with comptime-only types.
Diffstat (limited to 'test/cases/compile_errors')
| -rw-r--r-- | test/cases/compile_errors/comptime_only_global_align_section_addrspace.zig | 37 | ||||
| -rw-r--r-- | test/cases/compile_errors/invalid_variadic_function.zig | 5 |
2 files changed, 37 insertions, 5 deletions
diff --git a/test/cases/compile_errors/comptime_only_global_align_section_addrspace.zig b/test/cases/compile_errors/comptime_only_global_align_section_addrspace.zig new file mode 100644 index 0000000000..4ccc9ca18f --- /dev/null +++ b/test/cases/compile_errors/comptime_only_global_align_section_addrspace.zig @@ -0,0 +1,37 @@ +fn okay_func() void {} + +const a align(64) = okay_func; +const b addrspace(.generic) = okay_func; +const c linksection("irrelevant") = okay_func; + +const d align(64) = 1.23; +const e addrspace(.generic) = 1.23; +const f linksection("irrelevant") = 1.23; + +const g: comptime_float align(64) = 1.23; +const h: comptime_float addrspace(.generic) = 1.23; +const i: comptime_float linksection("irrelevant") = 1.23; + +// zig fmt: off +comptime { _ = a; } +comptime { _ = b; } +comptime { _ = c; } +comptime { _ = d; } +comptime { _ = e; } +comptime { _ = f; } +comptime { _ = g; } +comptime { _ = h; } +comptime { _ = i; } +// zig fmt: on + +// error +// +// :3:15: error: cannot specify alignment of function alias +// :4:20: error: cannot specify addrspace of function alias +// :5:21: error: cannot specify linksection of function alias +// :7:15: error: cannot specify alignment of comptime-only type +// :8:20: error: cannot specify addrspace of comptime-only type +// :9:21: error: cannot specify linksection of comptime-only type +// :11:31: error: cannot specify alignment of comptime-only type +// :12:36: error: cannot specify addrspace of comptime-only type +// :13:37: error: cannot specify linksection of comptime-only type diff --git a/test/cases/compile_errors/invalid_variadic_function.zig b/test/cases/compile_errors/invalid_variadic_function.zig index 9b7a4b40f3..cea9876892 100644 --- a/test/cases/compile_errors/invalid_variadic_function.zig +++ b/test/cases/compile_errors/invalid_variadic_function.zig @@ -1,14 +1,10 @@ fn foo(...) void {} -fn bar(a: anytype, ...) callconv(a) void {} inline fn foo2(...) void {} comptime { _ = foo; } comptime { - _ = bar; -} -comptime { _ = foo2; } @@ -19,4 +15,3 @@ comptime { // :1:1: note: supported calling conventions: 'x86_64_sysv', 'x86_64_win' // :1:1: error: variadic function does not support 'inline' calling convention // :1:1: note: supported calling conventions: 'x86_64_sysv', 'x86_64_win' -// :2:1: error: generic function cannot be variadic |
