resolver: Check IsStorable() earlier for array els
This was done in ValidateArray(), but this comes after the call to DefaultAlignAndSize(), which will ICE if the type is not storable.
Change-Id: Ia3f1b640f42a45362487c3156237b59ea6fed68b
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/53043
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
diff --git a/src/resolver/resolver.cc b/src/resolver/resolver.cc
index d94008a..2ac42f9 100644
--- a/src/resolver/resolver.cc
+++ b/src/resolver/resolver.cc
@@ -2653,6 +2653,14 @@
return nullptr;
}
+ if (!IsStorable(el_ty)) { // Check must come before DefaultAlignAndSize()
+ builder_->Diagnostics().add_error(
+ el_ty->FriendlyName(builder_->Symbols()) +
+ " cannot be used as an element type of an array",
+ source);
+ return nullptr;
+ }
+
uint32_t el_align = 0;
uint32_t el_size = 0;
if (!DefaultAlignAndSize(el_ty, el_align, el_size)) {
@@ -2702,14 +2710,6 @@
bool Resolver::ValidateArray(const sem::Array* arr, const Source& source) {
auto* el_ty = arr->ElemType();
- if (!IsStorable(el_ty)) {
- builder_->Diagnostics().add_error(
- el_ty->FriendlyName(builder_->Symbols()) +
- " cannot be used as an element type of an array",
- source);
- return false;
- }
-
if (auto* el_str = el_ty->As<sem::Struct>()) {
if (el_str->IsBlockDecorated()) {
// https://gpuweb.github.io/gpuweb/wgsl/#attributes