From 844d8d2212d11f3d28a55c81f234c99db2c26250 Mon Sep 17 00:00:00 2001 From: Darren Wihandi <65404740+fairywreath@users.noreply.github.com> Date: Fri, 21 Mar 2025 11:52:28 -0400 Subject: Emit errors for missing returns on unsupported targets (#6633) * initial wip * more WIP * preserve old lower behavior * remove unnecessary includes * add test * add no target case in test * fix broken test --------- Co-authored-by: Ellie Hermaszewska --- tests/diagnostics/missing-return-target.slang | 29 +++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 tests/diagnostics/missing-return-target.slang (limited to 'tests/diagnostics/missing-return-target.slang') diff --git a/tests/diagnostics/missing-return-target.slang b/tests/diagnostics/missing-return-target.slang new file mode 100644 index 000000000..8fc65efd1 --- /dev/null +++ b/tests/diagnostics/missing-return-target.slang @@ -0,0 +1,29 @@ +//DIAGNOSTIC_TEST:SIMPLE(filecheck=CHECK_NOT_SUPP): -entry computeMain -stage compute -target spirv +//DIAGNOSTIC_TEST:SIMPLE(filecheck=CHECK_NOT_SUPP): -entry computeMain -stage compute -target glsl +//DIAGNOSTIC_TEST:SIMPLE(filecheck=CHECK_NOT_SUPP): -entry computeMain -stage compute -target wgsl + +//DIAGNOSTIC_TEST:SIMPLE(filecheck=CHECK_SUPP): +//DIAGNOSTIC_TEST:SIMPLE(filecheck=CHECK_SUPP): -entry computeMain -stage compute -target hlsl +//DIAGNOSTIC_TEST:SIMPLE(filecheck=CHECK_SUPP): -entry computeMain -stage compute -target metal +//DIAGNOSTIC_TEST:SIMPLE(filecheck=CHECK_SUPP): -entry computeMain -stage compute -target cpp +//DIAGNOSTIC_TEST:SIMPLE(filecheck=CHECK_SUPP): -entry computeMain -stage compute -target cuda + +// Some compilation targets allow missing returns while some do not. +// This test ensures that either errors and warnings are emitted appropriately. + +RWStructuredBuffer out; + +// CHECK_NOT_SUPP: warning 41010: non-void function +// CHECK_NOT_SUPP: error 41009: non-void function + +// CHECK_SUPP: warning 41010: non-void function + +uint func() +{ +} + +[shader("compute")] +void computeMain() +{ + out[0] = func(); +} -- cgit v1.2.3