summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorTim Foley <tfoleyNV@users.noreply.github.com>2020-02-25 08:12:16 -0800
committerGitHub <noreply@github.com>2020-02-25 08:12:16 -0800
commit6308a1224672944220a1fee34ae22f70212703a0 (patch)
tree25d2011e23e64d2794dc1b07e2fa70785e13700f /tests
parentc4a32e34f68c5d202b8a4a867963a1ecbb03b96e (diff)
Fix a crash when a generic value argument isn't constant (#1241)
This arose when a user tried to specialize the DXR 1.1 `RayQuery` type to a local variable: ```hlsl RAY_FLAG rayFlags = RAY_FLAG_CULL_FRONT_FACING_TRIANGLES | RAY_FLAG_CULL_NON_OPAQUE; RayQuery<rayFlags> query; ``` In this case, we issued an error around `rayFlags` not being a constant as expected, but then we also crashes later on in checking because the `DeclRef` that was being used for the type had a null pointer for the generic argument corresponding to `rayFlags`. The main fix here was thus to add an `ErrorIntVal` case that can be used to represent something that should be an `IntVal` but where there was some kind of error in the input code so that the actual value isn't known to the compiler. A secondary fix here is that we were issuing error messages about expecting a constant for a parameter like `rayFlags` there *twice*, and one of those times was during the `JustChecking` part of overload resolution (when we are not supposed to emit any diagnostics). I fixed that up by allowing the `DiagnosticSink` to be used to be passed down explicitly (and allowing it to be null), while also leaving behind overloaded functions with the old signatures so that all the existing logic can continue to work unmodified.
Diffstat (limited to 'tests')
-rw-r--r--tests/bugs/ray-flags-non-constant.slang12
-rw-r--r--tests/bugs/ray-flags-non-constant.slang.expected6
2 files changed, 18 insertions, 0 deletions
diff --git a/tests/bugs/ray-flags-non-constant.slang b/tests/bugs/ray-flags-non-constant.slang
new file mode 100644
index 000000000..e2197c6cd
--- /dev/null
+++ b/tests/bugs/ray-flags-non-constant.slang
@@ -0,0 +1,12 @@
+// ray-flags-non-constant.slang
+
+// Regression test for a compiler crash occuring when a generic with integer
+// value parameters is specialized to a non-constant (and hence invalid) value.
+
+//TEST:SIMPLE:-target dxil-assembly -entry main -stage compute
+
+void main()
+{
+ RAY_FLAG rayFlags = RAY_FLAG_CULL_FRONT_FACING_TRIANGLES | RAY_FLAG_CULL_NON_OPAQUE;
+ RayQuery<rayFlags> query;
+}
diff --git a/tests/bugs/ray-flags-non-constant.slang.expected b/tests/bugs/ray-flags-non-constant.slang.expected
new file mode 100644
index 000000000..3c5ef5d07
--- /dev/null
+++ b/tests/bugs/ray-flags-non-constant.slang.expected
@@ -0,0 +1,6 @@
+result code = -1
+standard error = {
+tests/bugs/ray-flags-non-constant.slang(11): error 39999: expression does not evaluate to a compile-time constant
+}
+standard output = {
+}