Update parser to match * and & spec change.

The * and & operator grammar was updated in the spec to closer
match other languages. This CL updates the Tint WGSL parser to
match the current spec.

Bug: tint:1756
Change-Id: I81b7c373bbd6a540b9273813c63a29487e2907ce
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/111580
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
This commit is contained in:
dan sinclair
2022-11-23 21:33:11 +00:00
committed by Dawn LUCI CQ
parent d6800098e7
commit b785dc1e39
3 changed files with 81 additions and 39 deletions

View File

@@ -1298,6 +1298,23 @@ TEST_F(ResolverTest, U32_Overflow) {
EXPECT_EQ(r()->error(), "12:24 error: value 4294967296 cannot be represented as 'u32'");
}
// var a: array<i32,2>;
// *&a[0] = 1;
TEST_F(ResolverTest, PointerIndexing_Fail) {
// var a: array<i32,2>;
// let p = &a;
// *p[0] = 0;
auto* a = Var("a", ty.array<i32, 2>());
auto* p = AddressOf("a");
auto* idx = Assign(Deref(IndexAccessor(p, 0_u)), 0_u);
WrapInFunction(a, idx);
EXPECT_FALSE(r()->Resolve());
EXPECT_EQ(r()->error(), "error: cannot index type 'ptr<function, array<i32, 2>, read_write>'");
}
} // namespace
} // namespace tint::resolver