Enable -Wunused-but-set-variable.

Bug: chromium:1203071

Change-Id: I73e58baa9a581bfc72f191184998d68dba9941d6
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/59720
Auto-Submit: Peter Kasting <pkasting@google.com>
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
diff --git a/src/common/BUILD.gn b/src/common/BUILD.gn
index 372ee1b..afaa18f 100644
--- a/src/common/BUILD.gn
+++ b/src/common/BUILD.gn
@@ -120,6 +120,7 @@
       "-Wstrict-prototypes",
       "-Wtautological-unsigned-zero-compare",
       "-Wunreachable-code-aggressive",
+      "-Wunused-but-set-variable",
     ]
 
     if (is_win) {
diff --git a/src/dawn_native/ExternalTexture.cpp b/src/dawn_native/ExternalTexture.cpp
index 6b1cee8..254a556 100644
--- a/src/dawn_native/ExternalTexture.cpp
+++ b/src/dawn_native/ExternalTexture.cpp
@@ -59,6 +59,7 @@
 
         const Format* format;
         DAWN_TRY_ASSIGN(format, device->GetInternalFormat(descriptor->format));
+        DAWN_UNUSED(format);
 
         switch (descriptor->format) {
             case wgpu::TextureFormat::RGBA8Unorm:
diff --git a/src/dawn_native/SubresourceStorage.h b/src/dawn_native/SubresourceStorage.h
index 01bd686..16feffc 100644
--- a/src/dawn_native/SubresourceStorage.h
+++ b/src/dawn_native/SubresourceStorage.h
@@ -393,13 +393,11 @@
         ASSERT(mipLevel < mMipLevelCount);
 
         // Fastest path, the aspect is compressed!
-        uint32_t dataIndex = aspectIndex * mArrayLayerCount * mMipLevelCount;
         if (mAspectCompressed[aspectIndex]) {
             return DataInline(aspectIndex);
         }
 
         // Fast path, the array layer is compressed.
-        dataIndex += arrayLayer * mMipLevelCount;
         if (LayerCompressed(aspectIndex, arrayLayer)) {
             return Data(aspectIndex, arrayLayer);
         }
diff --git a/src/dawn_native/d3d12/CommandBufferD3D12.cpp b/src/dawn_native/d3d12/CommandBufferD3D12.cpp
index 7415911..26ef024 100644
--- a/src/dawn_native/d3d12/CommandBufferD3D12.cpp
+++ b/src/dawn_native/d3d12/CommandBufferD3D12.cpp
@@ -987,7 +987,6 @@
                                                 BindGroupStateTracker* bindingTracker,
                                                 const ComputePassResourceUsage& resourceUsages) {
         uint64_t currentDispatch = 0;
-        PipelineLayout* lastLayout = nullptr;
         ID3D12GraphicsCommandList* commandList = commandContext->GetCommandList();
 
         Command type;
@@ -1035,8 +1034,6 @@
                     commandList->SetPipelineState(pipeline->GetPipelineState());
 
                     bindingTracker->OnSetPipeline(pipeline);
-
-                    lastLayout = layout;
                     break;
                 }
 
diff --git a/src/dawn_native/d3d12/ResidencyManagerD3D12.cpp b/src/dawn_native/d3d12/ResidencyManagerD3D12.cpp
index fe4ecee..abf722f 100644
--- a/src/dawn_native/d3d12/ResidencyManagerD3D12.cpp
+++ b/src/dawn_native/d3d12/ResidencyManagerD3D12.cpp
@@ -184,6 +184,7 @@
         uint64_t bytesEvicted;
         DAWN_TRY_ASSIGN(bytesEvicted,
                         EnsureCanMakeResident(allocationSize, GetMemorySegmentInfo(memorySegment)));
+        DAWN_UNUSED(bytesEvicted);
 
         return {};
     }
@@ -298,6 +299,7 @@
                                                          ID3D12Pageable** allocations) {
         uint64_t bytesEvicted;
         DAWN_TRY_ASSIGN(bytesEvicted, EnsureCanMakeResident(sizeToMakeResident, segment));
+        DAWN_UNUSED(bytesEvicted);
 
         // Note that MakeResident is a synchronous function and can add a significant
         // overhead to command recording. In the future, it may be possible to decrease this