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 <jrprice@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
This commit is contained in:
James Price 2021-06-15 16:33:57 +00:00 committed by Tint LUCI CQ
parent 3184544182
commit 4daac0e64b
2 changed files with 18 additions and 1 deletions

View File

@ -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<ast::BindingDecoration>(0),
create<ast::GroupDecoration>(0),
ASTNodes().Create<ast::DisableValidationDecoration>(
ID(), ast::DisabledValidation::kBindingPointCollision),
ASTNodes().Create<ast::DisableValidationDecoration>(
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();

View File

@ -3340,7 +3340,7 @@ bool Resolver::ValidateNoDuplicateDecorations(
std::unordered_map<const TypeInfo*, Source> seen;
for (auto* d : decorations) {
auto res = seen.emplace(&d->TypeInfo(), d->source());
if (!res.second) {
if (!res.second && !d->Is<ast::InternalDecoration>()) {
diagnostics_.add_error("duplicate " + d->name() + " decoration",
d->source());
diagnostics_.add_note("first decoration declared here",