parser/wgsl: Error if type decorations are not consumed
Fixed: chromium:1230604 Change-Id: Ia847e58c30f2c5787db4c239d561e4fe5da01355 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/58761 Auto-Submit: Ben Clayton <bclayton@google.com> Commit-Queue: James Price <jrprice@google.com> Kokoro: Kokoro <noreply+kokoro@google.com> Reviewed-by: James Price <jrprice@google.com>
This commit is contained in:
parent
ac9db206eb
commit
0c3ddc9649
|
@ -1023,13 +1023,15 @@ Maybe<ast::Type*> ParserImpl::type_decl() {
|
||||||
return Failure::kErrored;
|
return Failure::kErrored;
|
||||||
|
|
||||||
auto type = type_decl(decos.value);
|
auto type = type_decl(decos.value);
|
||||||
if (type.errored)
|
if (type.errored) {
|
||||||
return Failure::kErrored;
|
return Failure::kErrored;
|
||||||
if (!type.matched)
|
}
|
||||||
|
if (!expect_decorations_consumed(decos.value)) {
|
||||||
|
return Failure::kErrored;
|
||||||
|
}
|
||||||
|
if (!type.matched) {
|
||||||
return Failure::kNoMatch;
|
return Failure::kNoMatch;
|
||||||
|
}
|
||||||
if (!expect_decorations_consumed(decos.value))
|
|
||||||
return Failure::kErrored;
|
|
||||||
|
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
|
@ -422,6 +422,13 @@ TEST_F(ParserImplErrorTest, FunctionDeclMissingRBrace) {
|
||||||
" ^\n");
|
" ^\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(ParserImplErrorTest, FunctionScopeUnusedDecl) {
|
||||||
|
EXPECT("fn f(a:i32)->i32{return a;[[size(1)]]}",
|
||||||
|
"test.wgsl:1:29 error: unexpected decorations\n"
|
||||||
|
"fn f(a:i32)->i32{return a;[[size(1)]]}\n"
|
||||||
|
" ^^^^\n");
|
||||||
|
}
|
||||||
|
|
||||||
TEST_F(ParserImplErrorTest, FunctionMissingOpenLine) {
|
TEST_F(ParserImplErrorTest, FunctionMissingOpenLine) {
|
||||||
EXPECT(R"(let bar : vec2<f32> = vec2<f32>(1., 2.);
|
EXPECT(R"(let bar : vec2<f32> = vec2<f32>(1., 2.);
|
||||||
var a : f32 = bar[0];
|
var a : f32 = bar[0];
|
||||||
|
|
Loading…
Reference in New Issue