diff options
| -rw-r--r-- | source/slang/parser.cpp | 4 | ||||
| -rw-r--r-- | tests/parser/cast-precedence.hlsl | 15 |
2 files changed, 18 insertions, 1 deletions
diff --git a/source/slang/parser.cpp b/source/slang/parser.cpp index 38d9c744d..a0e07ea12 100644 --- a/source/slang/parser.cpp +++ b/source/slang/parser.cpp @@ -3321,6 +3321,8 @@ namespace Slang return parseGenericApp(parser, base); } + static RefPtr<Expr> parsePrefixExpr(Parser* parser); + static RefPtr<Expr> parseAtomicExpr(Parser* parser) { switch( peekTokenType(parser) ) @@ -3348,7 +3350,7 @@ namespace Slang tcexpr->FunctionExpr = parser->ParseType(); parser->ReadToken(TokenType::RParent); - auto arg = parser->ParseExpression(Precedence::Multiplicative); // Note(tfoley): need to double-check this + auto arg = parsePrefixExpr(parser); tcexpr->Arguments.Add(arg); return tcexpr; 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; +} |
