From fe5eef423389b82e7eb2586fb7a16b96afd004f2 Mon Sep 17 00:00:00 2001 From: Tim Foley Date: Mon, 9 Oct 2017 10:16:12 -0700 Subject: 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. --- tests/parser/cast-precedence.hlsl | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 tests/parser/cast-precedence.hlsl (limited to 'tests/parser') 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; +} -- cgit v1.2.3