From 2252dcc508c53dc302ec1f919c4792a7f00ce125 Mon Sep 17 00:00:00 2001 From: Bogdan Romanyuk <65823030+wrongnull@users.noreply.github.com> Date: Sat, 25 Nov 2023 20:29:07 +0300 Subject: Compiler: move checking function-scope-only builtins to AstGen --- .../function-only_builtins_outside_function.zig | 69 ++++++++++++++++++++++ .../setAlignStack_outside_function.zig | 9 --- test/cases/compile_errors/src_outside_function.zig | 9 --- 3 files changed, 69 insertions(+), 18 deletions(-) create mode 100644 test/cases/compile_errors/function-only_builtins_outside_function.zig delete mode 100644 test/cases/compile_errors/setAlignStack_outside_function.zig delete mode 100644 test/cases/compile_errors/src_outside_function.zig (limited to 'test') diff --git a/test/cases/compile_errors/function-only_builtins_outside_function.zig b/test/cases/compile_errors/function-only_builtins_outside_function.zig new file mode 100644 index 0000000000..3484b5ca46 --- /dev/null +++ b/test/cases/compile_errors/function-only_builtins_outside_function.zig @@ -0,0 +1,69 @@ +comptime { + @setAlignStack(1); +} + +comptime { + @setCold(true); +} + +comptime { + @src(); +} + +comptime { + @returnAddress(); +} + +comptime { + @frameAddress(); +} + +comptime { + @breakpoint(); +} + +comptime { + @cVaArg(1, 2); +} + +comptime { + @cVaCopy(1); +} + +comptime { + @cVaEnd(1); +} + +comptime { + @cVaStart(); +} + +comptime { + @workItemId(42); +} + +comptime { + @workGroupSize(42); +} + +comptime { + @workGroupId(42); +} + +// error +// backend=stage2 +// target=native +// +// :2:5: error: '@setAlignStack' outside function scope +// :6:5: error: '@setCold' outside function scope +// :10:5: error: '@src' outside function scope +// :14:5: error: '@returnAddress' outside function scope +// :18:5: error: '@frameAddress' outside function scope +// :22:5: error: '@breakpoint' outside function scope +// :26:5: error: '@cVaArg' outside function scope +// :30:5: error: '@cVaCopy' outside function scope +// :34:5: error: '@cVaEnd' outside function scope +// :38:5: error: '@cVaStart' outside function scope +// :42:5: error: '@workItemId' outside function scope +// :46:5: error: '@workGroupSize' outside function scope +// :50:5: error: '@workGroupId' outside function scope diff --git a/test/cases/compile_errors/setAlignStack_outside_function.zig b/test/cases/compile_errors/setAlignStack_outside_function.zig deleted file mode 100644 index 0c06f867de..0000000000 --- a/test/cases/compile_errors/setAlignStack_outside_function.zig +++ /dev/null @@ -1,9 +0,0 @@ -comptime { - @setAlignStack(16); -} - -// error -// backend=stage2 -// target=native -// -// :2:5: error: @setAlignStack outside function body diff --git a/test/cases/compile_errors/src_outside_function.zig b/test/cases/compile_errors/src_outside_function.zig deleted file mode 100644 index 8b66ba730b..0000000000 --- a/test/cases/compile_errors/src_outside_function.zig +++ /dev/null @@ -1,9 +0,0 @@ -comptime { - @src(); -} - -// error -// backend=stage2 -// target=native -// -// :2:5: error: @src outside function -- cgit v1.2.3