summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/diagnostics/parameter-already-defined.slang.expected3
-rw-r--r--tests/diagnostics/variable-redeclaration.slang54
-rw-r--r--tests/diagnostics/variable-redeclaration.slang.expected16
3 files changed, 72 insertions, 1 deletions
diff --git a/tests/diagnostics/parameter-already-defined.slang.expected b/tests/diagnostics/parameter-already-defined.slang.expected
index ae7546a10..b748b9523 100644
--- a/tests/diagnostics/parameter-already-defined.slang.expected
+++ b/tests/diagnostics/parameter-already-defined.slang.expected
@@ -1,6 +1,7 @@
result code = -1
standard error = {
-tests/diagnostics/parameter-already-defined.slang(4): error 30002: parameter 'a' already defined.
+tests/diagnostics/parameter-already-defined.slang(4): error 30200: declaration of 'a' conflicts with existing declaration
+tests/diagnostics/parameter-already-defined.slang(4): note: see previous declaration of 'a'
}
standard output = {
}
diff --git a/tests/diagnostics/variable-redeclaration.slang b/tests/diagnostics/variable-redeclaration.slang
new file mode 100644
index 000000000..bbd6a07c0
--- /dev/null
+++ b/tests/diagnostics/variable-redeclaration.slang
@@ -0,0 +1,54 @@
+// variable-redeclaration.slang
+
+//DIAGNOSTIC_TEST:SIMPLE:
+
+
+// This test confirms that the compiler produces
+// suitable diagnostics when variables are redeclared
+// in a given scope.
+
+// Global variables, including shader parameters
+
+static int gA;
+
+static Texture2D gA;
+
+// Local variables
+
+int testLocalRedeclaration(int x)
+{
+ int y = x;
+ int y = x;
+}
+
+int testLocalShadowing(int x)
+{
+ int y = x;
+ {
+ // Because this declaration is in an inner
+ // scope it should shadow the existing `y`
+ // rather than conflcit with it.
+ //
+ // TODO: It would be reasonable for the
+ // compiler to warn on this sort of code.
+ //
+ int y = x;
+ }
+}
+
+// Structure fields
+
+struct S
+{
+ int f;
+ float f;
+}
+
+// Function parameter list
+
+int testParameterRedeclaration(
+ int size,
+ float size)
+{
+ return size;
+}
diff --git a/tests/diagnostics/variable-redeclaration.slang.expected b/tests/diagnostics/variable-redeclaration.slang.expected
new file mode 100644
index 000000000..d49c4512f
--- /dev/null
+++ b/tests/diagnostics/variable-redeclaration.slang.expected
@@ -0,0 +1,16 @@
+result code = -1
+standard error = {
+tests/diagnostics/variable-redeclaration.slang(14): error 30200: declaration of 'gA' conflicts with existing declaration
+tests/diagnostics/variable-redeclaration.slang(12): note: see previous declaration of 'gA'
+tests/diagnostics/variable-redeclaration.slang(44): error 30200: declaration of 'f' conflicts with existing declaration
+tests/diagnostics/variable-redeclaration.slang(43): note: see previous declaration of 'f'
+tests/diagnostics/variable-redeclaration.slang(51): error 30200: declaration of 'size' conflicts with existing declaration
+tests/diagnostics/variable-redeclaration.slang(50): note: see previous declaration of 'size'
+tests/diagnostics/variable-redeclaration.slang(21): error 30200: declaration of 'y' conflicts with existing declaration
+tests/diagnostics/variable-redeclaration.slang(20): note: see previous declaration of 'y'
+tests/diagnostics/variable-redeclaration.slang(53): error 39999: ambiguous reference to 'size'
+tests/diagnostics/variable-redeclaration.slang(51): note 39999: candidate: size
+tests/diagnostics/variable-redeclaration.slang(50): note 39999: candidate: size
+}
+standard output = {
+}