transform/BindingRemapper: Error if attempting to change access control of non-storage var

The clusterfuzz fuzzers are attempting to change the access control of a uniform variable, which produces a program that does not validate.

Create an error diagnostic tagged with diag::System::Transform, which the fuzzers recognise as being invalid configuration to the transform.

Fixed: chromium:1244999
Change-Id: I2d4f2dfd4f2218ac81172003872494acb027323b
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/63141
Auto-Submit: Ben Clayton <bclayton@google.com>
Commit-Queue: David Neto <dneto@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: David Neto <dneto@google.com>
diff --git a/src/transform/binding_remapper.cc b/src/transform/binding_remapper.cc
index ce6a812..67d47cd 100644
--- a/src/transform/binding_remapper.cc
+++ b/src/transform/binding_remapper.cc
@@ -113,7 +113,15 @@
       auto ac_it = remappings->access_controls.find(from);
       if (ac_it != remappings->access_controls.end()) {
         ast::Access ac = ac_it->second;
-        auto* ty = ctx.src->Sem().Get(var)->Type()->UnwrapRef();
+        auto* sem = ctx.src->Sem().Get(var);
+        if (sem->StorageClass() != ast::StorageClass::kStorage) {
+          ctx.dst->Diagnostics().add_error(
+              diag::System::Transform,
+              "cannot apply access control to variable with storage class " +
+                  std::string(ast::str(sem->StorageClass())));
+          return;
+        }
+        auto* ty = sem->Type()->UnwrapRef();
         ast::Type* inner_ty = CreateASTTypeFor(ctx, ty);
         auto* new_var = ctx.dst->create<ast::Variable>(
             ctx.Clone(var->source()), ctx.Clone(var->symbol()),