[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 authored and Dzmitry Malyshau committed 2021-08-19 16:51:10 -04:00
1 parent f14817e8a0
commit fc47008d0c
2 files changed
+20 -1

No files matched your search

+2
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(_)
+18 -1
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();
}