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>
diff --git a/docs/origin-trial-changes.md b/docs/origin-trial-changes.md index 154c510..100dac5 100644 --- a/docs/origin-trial-changes.md +++ b/docs/origin-trial-changes.md
@@ -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
diff --git a/src/reader/wgsl/parser_impl.cc b/src/reader/wgsl/parser_impl.cc index 6845fbd..9112b18 100644 --- a/src/reader/wgsl/parser_impl.cc +++ b/src/reader/wgsl/parser_impl.cc
@@ -3133,6 +3133,7 @@ } if (s == kBlockDecoration) { + deprecated(t.source(), "[[block]] attributes have been removed from WGSL"); return create<ast::StructBlockDecoration>(t.source()); }
diff --git a/src/reader/wgsl/parser_impl_error_msg_test.cc b/src/reader/wgsl/parser_impl_error_msg_test.cc index 79ab884..7c1d391 100644 --- a/src/reader/wgsl/parser_impl_error_msg_test.cc +++ b/src/reader/wgsl/parser_impl_error_msg_test.cc
@@ -52,10 +52,10 @@ } 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 @@ " ^\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");
diff --git a/src/reader/wgsl/parser_impl_global_decl_test.cc b/src/reader/wgsl/parser_impl_global_decl_test.cc index ff21c57..175947c 100644 --- a/src/reader/wgsl/parser_impl_global_decl_test.cc +++ b/src/reader/wgsl/parser_impl_global_decl_test.cc
@@ -193,6 +193,7 @@ 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_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
diff --git a/src/reader/wgsl/parser_impl_struct_decl_test.cc b/src/reader/wgsl/parser_impl_struct_decl_test.cc index 4f041b5..8d411ff 100644 --- a/src/reader/wgsl/parser_impl_struct_decl_test.cc +++ b/src/reader/wgsl/parser_impl_struct_decl_test.cc
@@ -139,6 +139,7 @@ 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 @@ 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();
diff --git a/src/reader/wgsl/parser_impl_struct_decoration_decl_test.cc b/src/reader/wgsl/parser_impl_struct_decoration_decl_test.cc index 05eb0fc..655bb19 100644 --- a/src/reader/wgsl/parser_impl_struct_decoration_decl_test.cc +++ b/src/reader/wgsl/parser_impl_struct_decoration_decl_test.cc
@@ -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 { 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) {