summaryrefslogtreecommitdiffstats
path: root/tests/parser
diff options
context:
space:
mode:
authorTim Foley <tfoleyNV@users.noreply.github.com>2017-10-09 10:16:12 -0700
committerGitHub <noreply@github.com>2017-10-09 10:16:12 -0700
commitfe5eef423389b82e7eb2586fb7a16b96afd004f2 (patch)
tree83b20983dc33dfaa664c7b8875ea93d2976a31a9 /tests/parser
parentfaf26afdcfd343c79517f56f215bf8dcd5e0b992 (diff)
Parser: fix precedence of cast expressions (#203)
We were accidentally parsing this: (uint) a / b as this: (uint) ( a / b ) when it should be: ((uint) a) / b This is a bug that seems to have been inherited from a long time ago. It has taken a while to bite anybody because the only class of expressions it would hit are multiplicative ones, and in many cases the difference in the cast order won't be noticed for values in a limited range.
Diffstat (limited to 'tests/parser')
-rw-r--r--tests/parser/cast-precedence.hlsl15
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/parser/cast-precedence.hlsl b/tests/parser/cast-precedence.hlsl
new file mode 100644
index 000000000..d5d0b0322
--- /dev/null
+++ b/tests/parser/cast-precedence.hlsl
@@ -0,0 +1,15 @@
+//TEST:COMPARE_HLSL: -profile vs_5_0
+
+// Confirm that type-cast expressions parse with
+// the appropriate precedence.
+
+cbuffer C : register(b0)
+{
+ float a;
+ float b;
+};
+
+float4 main() : SV_Position
+{
+ return (uint) a / b;
+}