From 4daac0e64b3455369be9baf78ed4317363135d25 Mon Sep 17 00:00:00 2001 From: James Price Date: Tue, 15 Jun 2021 16:33:57 +0000 Subject: [PATCH] resolver: Allow multiple internal decorations Sometimes a stack of transforms will generate multiple different DisableValidationDecorations on a single node. Change-Id: Id4afa148360f98796e67017a9bbdd8adf12eed58 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/54700 Auto-Submit: James Price Commit-Queue: Ben Clayton Kokoro: Kokoro Reviewed-by: Ben Clayton --- src/resolver/decoration_validation_test.cc | 17 +++++++++++++++++ src/resolver/resolver.cc | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/resolver/decoration_validation_test.cc b/src/resolver/decoration_validation_test.cc index 1296d30e7e..664bb92eeb 100644 --- a/src/resolver/decoration_validation_test.cc +++ b/src/resolver/decoration_validation_test.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "src/ast/access_decoration.h" +#include "src/ast/disable_validation_decoration.h" #include "src/ast/override_decoration.h" #include "src/ast/return_statement.h" #include "src/ast/stage_decoration.h" @@ -377,6 +378,22 @@ TEST_F(VariableDecorationTest, DuplicateDecoration) { 12:34 note: first decoration declared here)"); } +TEST_F(VariableDecorationTest, DuplicateInternalDecoration) { + auto* s = + Param("s", ty.sampler(ast::SamplerKind::kSampler), + ast::DecorationList{ + create(0), + create(0), + ASTNodes().Create( + ID(), ast::DisabledValidation::kBindingPointCollision), + ASTNodes().Create( + ID(), ast::DisabledValidation::kEntryPointParameter), + }); + Func("f", {s}, ty.void_(), {}); + + EXPECT_TRUE(r()->Resolve()) << r()->error(); +} + using ConstantDecorationTest = TestWithParams; TEST_P(ConstantDecorationTest, IsValid) { auto& params = GetParam(); diff --git a/src/resolver/resolver.cc b/src/resolver/resolver.cc index 4ba075dbec..6d32fff355 100644 --- a/src/resolver/resolver.cc +++ b/src/resolver/resolver.cc @@ -3340,7 +3340,7 @@ bool Resolver::ValidateNoDuplicateDecorations( std::unordered_map seen; for (auto* d : decorations) { auto res = seen.emplace(&d->TypeInfo(), d->source()); - if (!res.second) { + if (!res.second && !d->Is()) { diagnostics_.add_error("duplicate " + d->name() + " decoration", d->source()); diagnostics_.add_note("first decoration declared here",