reader/wgsl: Deprecate the [[block]] attribute

Bug: tint:1324
Change-Id: Ic8e9cd4a2e924498397659b5d23d6ac6d602588d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/72088
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
This commit is contained in:
James Price 2021-12-09 15:45:03 +00:00
parent a5d3986a0a
commit 170a50353c
6 changed files with 32 additions and 14 deletions

View File

@ -11,6 +11,7 @@
### Deprecated Features
* The `isNan()`, `isInf()`, `isFinite()` and `isNormal()` builtins has been deprecated and will be removed in M101. [tint:1312](https://crbug.com/tint/1312)
* The `[[block]]` attribute has been deprecated and will be removed in M101. [tint:1324](https://crbug.com/tint/1324)
### New Features

View File

@ -3133,6 +3133,7 @@ Maybe<const ast::Decoration*> ParserImpl::decoration() {
}
if (s == kBlockDecoration) {
deprecated(t.source(), "[[block]] attributes have been removed from WGSL");
return create<ast::StructBlockDecoration>(t.source());
}

View File

@ -52,10 +52,10 @@ TEST_F(ParserImplErrorTest, AndInvalidExpr) {
}
TEST_F(ParserImplErrorTest, AliasDeclInvalidDeco) {
EXPECT("[[block]]type e=u32;",
EXPECT("[[override]]type e=u32;",
"test.wgsl:1:3 error: unexpected decorations\n"
"[[block]]type e=u32;\n"
" ^^^^^\n");
"[[override]]type e=u32;\n"
" ^^^^^^^^\n");
}
TEST_F(ParserImplErrorTest, IndexExprInvalidExpr) {
@ -605,15 +605,25 @@ TEST_F(ParserImplErrorTest, GlobalDeclStorageTextureMissingInvalidSubtype) {
" ^\n");
}
// TODO(crbug.com/tint/1324): DEPRECATED: Remove when [[block]] is removed.
TEST_F(ParserImplErrorTest, GlobalDeclStructDecoMissingStruct) {
EXPECT("[[block]];",
"test.wgsl:1:3 warning: use of deprecated language feature: [[block]] "
"attributes have been removed from WGSL\n"
"[[block]];\n"
" ^^^^^\n\n"
"test.wgsl:1:10 error: expected declaration after decorations\n"
"[[block]];\n"
" ^\n");
}
// TODO(crbug.com/tint/1324): DEPRECATED: Remove when [[block]] is removed.
TEST_F(ParserImplErrorTest, GlobalDeclStructDecoMissingEnd) {
EXPECT("[[block struct {};",
"test.wgsl:1:3 warning: use of deprecated language feature: [[block]] "
"attributes have been removed from WGSL\n"
"[[block struct {};\n"
" ^^^^^\n\n"
"test.wgsl:1:9 error: expected ']]' for decoration list\n"
"[[block struct {};\n"
" ^^^^^^\n");

View File

@ -193,6 +193,7 @@ TEST_F(ParserImplTest, GlobalDecl_Struct_WithStride) {
ASSERT_EQ(stride->As<ast::StrideDecoration>()->stride, 4u);
}
// TODO(crbug.com/tint/1324): DEPRECATED: Remove when [[block]] is removed.
TEST_F(ParserImplTest, GlobalDecl_Struct_WithDecoration) {
auto p = parser("[[block]] struct A { data: f32; };");
p->expect_global_decl();
@ -211,17 +212,17 @@ TEST_F(ParserImplTest, GlobalDecl_Struct_WithDecoration) {
}
TEST_F(ParserImplTest, GlobalDecl_Struct_Invalid) {
auto p = parser("[[block]] A {};");
auto p = parser("A {};");
p->expect_global_decl();
ASSERT_TRUE(p->has_error());
EXPECT_EQ(p->error(), "1:11: expected declaration after decorations");
EXPECT_EQ(p->error(), "1:1: unexpected token");
}
TEST_F(ParserImplTest, GlobalDecl_StructMissing_Semi) {
auto p = parser("[[block]] struct A {}");
auto p = parser("struct A {}");
p->expect_global_decl();
ASSERT_TRUE(p->has_error());
EXPECT_EQ(p->error(), "1:22: expected ';' for struct declaration");
EXPECT_EQ(p->error(), "1:12: expected ';' for struct declaration");
}
} // namespace

View File

@ -139,6 +139,7 @@ TEST_F(ParserImplTest, StructDecl_MissingBracketLeft) {
EXPECT_EQ(p->error(), "1:10: expected '{' for struct declaration");
}
// TODO(crbug.com/tint/1324): DEPRECATED: Remove when [[block]] is removed.
TEST_F(ParserImplTest, StructDecl_InvalidDecorationDecl) {
auto p = parser("[[block struct S { a : i32; }");
auto decos = p->decoration_list();
@ -151,9 +152,13 @@ TEST_F(ParserImplTest, StructDecl_InvalidDecorationDecl) {
EXPECT_NE(s.value, nullptr);
EXPECT_TRUE(p->has_error());
EXPECT_EQ(p->error(), "1:9: expected ']]' for decoration list");
EXPECT_EQ(
p->error(),
R"(1:3: use of deprecated language feature: [[block]] attributes have been removed from WGSL
1:9: expected ']]' for decoration list)");
}
// TODO(crbug.com/tint/1324): DEPRECATED: Remove when [[block]] is removed.
TEST_F(ParserImplTest, StructDecl_MissingStruct) {
auto p = parser("[[block]] S {}");
auto decos = p->decoration_list();

View File

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#include "src/ast/struct_block_decoration.h"
#include "src/ast/override_decoration.h"
#include "src/reader/wgsl/parser_impl_test_helper.h"
namespace tint {
@ -21,24 +21,24 @@ namespace wgsl {
namespace {
TEST_F(ParserImplTest, DecorationDecl_Parses) {
auto p = parser("[[block]]");
auto p = parser("[[override]]");
auto decos = p->decoration_list();
EXPECT_FALSE(p->has_error());
EXPECT_FALSE(decos.errored);
EXPECT_TRUE(decos.matched);
ASSERT_EQ(decos.value.size(), 1u);
auto* struct_deco = decos.value[0]->As<ast::Decoration>();
EXPECT_TRUE(struct_deco->Is<ast::StructBlockDecoration>());
auto* override_deco = decos.value[0]->As<ast::Decoration>();
EXPECT_TRUE(override_deco->Is<ast::OverrideDecoration>());
}
TEST_F(ParserImplTest, DecorationDecl_MissingAttrRight) {
auto p = parser("[[block");
auto p = parser("[[override");
auto decos = p->decoration_list();
EXPECT_TRUE(p->has_error());
EXPECT_TRUE(decos.errored);
EXPECT_FALSE(decos.matched);
EXPECT_TRUE(decos.value.empty());
EXPECT_EQ(p->error(), "1:8: expected ']]' for decoration list");
EXPECT_EQ(p->error(), "1:11: expected ']]' for decoration list");
}
TEST_F(ParserImplTest, DecorationDecl_InvalidDecoration) {