tint/resolver: Allow array sizes to be unnamed override-expressions

I got the rules around this wrong. This should be allowed, but the array types cannot compare equal if they are unnamed override-expressions.

Fixed tint:1737

Change-Id: I83dc49703eed015e9c183e804474886da5dad7b9
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/107685
Reviewed-by: James Price <jrprice@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Auto-Submit: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
This commit is contained in:
Ben Clayton
2022-10-31 17:26:10 +00:00
committed by Dawn LUCI CQ
parent cc85ed6dd1
commit 22c4850b06
14 changed files with 306 additions and 58 deletions

View File

@@ -114,10 +114,14 @@ const ast::Type* Transform::CreateASTTypeFor(CloneContext& ctx, const sem::Type*
if (a->IsRuntimeSized()) {
return ctx.dst->ty.array(el, nullptr, std::move(attrs));
}
if (auto* override = std::get_if<sem::OverrideArrayCount>(&a->Count())) {
if (auto* override = std::get_if<sem::NamedOverrideArrayCount>(&a->Count())) {
auto* count = ctx.Clone(override->variable->Declaration());
return ctx.dst->ty.array(el, count, std::move(attrs));
}
if (auto* override = std::get_if<sem::UnnamedOverrideArrayCount>(&a->Count())) {
auto* count = ctx.Clone(override->expr->Declaration());
return ctx.dst->ty.array(el, count, std::move(attrs));
}
if (auto count = a->ConstantCount()) {
return ctx.dst->ty.array(el, u32(count.value()), std::move(attrs));
}