summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/diagnostics/local-used-before-declared.slang21
-rw-r--r--tests/diagnostics/local-used-before-declared.slang.expected6
-rw-r--r--tests/diagnostics/local-used-in-own-declaration.slang19
-rw-r--r--tests/diagnostics/local-used-in-own-declaration.slang.expected6
4 files changed, 52 insertions, 0 deletions
diff --git a/tests/diagnostics/local-used-before-declared.slang b/tests/diagnostics/local-used-before-declared.slang
new file mode 100644
index 000000000..96d68b9eb
--- /dev/null
+++ b/tests/diagnostics/local-used-before-declared.slang
@@ -0,0 +1,21 @@
+//TEST:SIMPLE:-target dxbc -profile ps_5_0 -entry main
+
+// Early versions of the front-end had bugs when local
+// variables were used before their definition, or
+// were defined using a reference to themselves.
+//
+// This file tries to ensure that we emit proper error
+// diagnostics in these cases.
+
+void usedBeforeDeclared()
+{
+ // b is used before it is declared
+ float c = d + 1.0;
+ int d = 0;
+}
+
+float4 main()
+{
+ usedBeforeDeclared();
+ return 0;
+} \ No newline at end of file
diff --git a/tests/diagnostics/local-used-before-declared.slang.expected b/tests/diagnostics/local-used-before-declared.slang.expected
new file mode 100644
index 000000000..a248fa969
--- /dev/null
+++ b/tests/diagnostics/local-used-before-declared.slang.expected
@@ -0,0 +1,6 @@
+result code = -1
+standard error = {
+tests/diagnostics/local-used-before-declared.slang(14): fatal error 39999: local variable 'd' is being used before its declaration.
+}
+standard output = {
+}
diff --git a/tests/diagnostics/local-used-in-own-declaration.slang b/tests/diagnostics/local-used-in-own-declaration.slang
new file mode 100644
index 000000000..9802acbb9
--- /dev/null
+++ b/tests/diagnostics/local-used-in-own-declaration.slang
@@ -0,0 +1,19 @@
+//TEST:SIMPLE:-target dxbc -profile ps_5_0
+
+// Early versions of the front-end had bugs when local
+// variables were used before their definition, or
+// were defined using a reference to themselves.
+//
+// This file tries to ensure that we emit proper error
+// diagnostics in these cases.
+
+void usedInOwnDeclaration()
+{
+ int e = e;
+}
+
+float4 main()
+{
+ usedInOwnDeclaration();
+ return 0;
+} \ No newline at end of file
diff --git a/tests/diagnostics/local-used-in-own-declaration.slang.expected b/tests/diagnostics/local-used-in-own-declaration.slang.expected
new file mode 100644
index 000000000..a1421a158
--- /dev/null
+++ b/tests/diagnostics/local-used-in-own-declaration.slang.expected
@@ -0,0 +1,6 @@
+result code = -1
+standard error = {
+tests/diagnostics/local-used-in-own-declaration.slang(12): fatal error 39999: local variable 'e' is being used before its declaration.
+}
+standard output = {
+}