[glsl-in] Allow expression statements to begin with ++ or --

This would otherwise cause the parser to enter an infinite loop.

Fixes #1232
This commit is contained in:
João Capucho
2021-08-19 20:56:44 +01:00
committed by Dzmitry Malyshau
parent f14817e8a0
commit fc47008d0c
2 changed files with 20 additions and 1 deletions

View File

@@ -495,6 +495,8 @@ impl<'source> ParsingContext<'source> {
| TokenValue::Bang
| TokenValue::Tilde
| TokenValue::LeftParen
| TokenValue::Increment
| TokenValue::Decrement
| TokenValue::Identifier(_)
| TokenValue::TypeName(_)
| TokenValue::IntConstant(_)

View File

@@ -778,9 +778,10 @@ fn swizzles() {
}
#[test]
fn vector_indexing() {
fn expressions() {
let mut parser = Parser::default();
// Vector indexing
parser
.parse(
&Options::from(ShaderStage::Vertex),
@@ -795,4 +796,20 @@ fn vector_indexing() {
"#,
)
.unwrap();
// Prefix increment/decrement
parser
.parse(
&Options::from(ShaderStage::Vertex),
r#"
# version 450
void main() {
uint index = 0;
--index;
++index;
}
"#,
)
.unwrap();
}