summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorDarren Wihandi <65404740+fairywreath@users.noreply.github.com>2025-03-21 11:52:28 -0400
committerGitHub <noreply@github.com>2025-03-21 15:52:28 +0000
commit844d8d2212d11f3d28a55c81f234c99db2c26250 (patch)
treef541932dc6fca77f8b0f5ad869644a674d60fccf /tests
parent16ac0efa3e1e834e3b12af8ac34cf47a6418bb34 (diff)
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 <ellieh@nvidia.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/diagnostics/missing-return-target.slang29
-rw-r--r--tests/hlsl/tbuffer.slang2
2 files changed, 30 insertions, 1 deletions
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<uint> 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();
+}
diff --git a/tests/hlsl/tbuffer.slang b/tests/hlsl/tbuffer.slang
index a1bebf2e1..cb014bf2b 100644
--- a/tests/hlsl/tbuffer.slang
+++ b/tests/hlsl/tbuffer.slang
@@ -35,6 +35,6 @@ tbuffer tbuf2 : register(t1)
RWStructuredBuffer<float4> outputBuffer;
[numthreads(1,1,1)]
-float4 computeMain() {
+void computeMain() {
outputBuffer[0] = tb_val1 + texture2D[0] + tb_val2;
}