Fix -Wunreachable-code-aggressive.

Bug: chromium:1066980
Change-Id: I9e00d3707972307e1c5395156c39aa153d5e170e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/56522
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Peter Kasting <pkasting@google.com>
Commit-Queue: Peter Kasting <pkasting@google.com>
Auto-Submit: Peter Kasting <pkasting@google.com>
diff --git a/generator/templates/dawn_wire/server/ServerDoers.cpp b/generator/templates/dawn_wire/server/ServerDoers.cpp
index 7a70577..0c3031c 100644
--- a/generator/templates/dawn_wire/server/ServerDoers.cpp
+++ b/generator/templates/dawn_wire/server/ServerDoers.cpp
@@ -118,8 +118,6 @@
             default:
                 return false;
         }
-
-        return true;
     }
 
 }}  // namespace dawn_wire::server
diff --git a/src/common/BUILD.gn b/src/common/BUILD.gn
index dd76c2a..e34df57 100644
--- a/src/common/BUILD.gn
+++ b/src/common/BUILD.gn
@@ -119,6 +119,7 @@
       "-Wshadow-field",
       "-Wstrict-prototypes",
       "-Wtautological-unsigned-zero-compare",
+      "-Wunreachable-code-aggressive",
     ]
 
     if (is_win) {
diff --git a/src/dawn_native/CommandEncoder.cpp b/src/dawn_native/CommandEncoder.cpp
index 507c3b1..1c1cd72 100644
--- a/src/dawn_native/CommandEncoder.cpp
+++ b/src/dawn_native/CommandEncoder.cpp
@@ -105,7 +105,6 @@
                         return DAWN_VALIDATION_ERROR(
                             "The depth aspect of depth24plus texture cannot be selected in a "
                             "texture to buffer copy");
-                        break;
                     case wgpu::TextureFormat::Depth32Float:
                         break;
 
diff --git a/src/dawn_native/CommandValidation.cpp b/src/dawn_native/CommandValidation.cpp
index 65c8743..a5b0543 100644
--- a/src/dawn_native/CommandValidation.cpp
+++ b/src/dawn_native/CommandValidation.cpp
@@ -368,12 +368,10 @@
                 if (HasOneBit(format.aspects)) {
                     Aspect single = format.aspects;
                     return single;
-                } else {
-                    return DAWN_VALIDATION_ERROR(
-                        "A single aspect must be selected for multi-planar formats in "
-                        "texture <-> linear data copies");
                 }
-                break;
+                return DAWN_VALIDATION_ERROR(
+                    "A single aspect must be selected for multi-planar formats in "
+                    "texture <-> linear data copies");
             case wgpu::TextureAspect::DepthOnly:
                 ASSERT(format.aspects & Aspect::Depth);
                 return Aspect::Depth;
diff --git a/src/dawn_native/ShaderModule.cpp b/src/dawn_native/ShaderModule.cpp
index 8a07a59..4a05cb1 100644
--- a/src/dawn_native/ShaderModule.cpp
+++ b/src/dawn_native/ShaderModule.cpp
@@ -784,7 +784,6 @@
                         }
                         case BindingInfoType::ExternalTexture: {
                             return DAWN_VALIDATION_ERROR("External textures are not supported.");
-                            break;
                         }
                     }
                 }
diff --git a/src/dawn_native/Surface.cpp b/src/dawn_native/Surface.cpp
index ba398fc..5da7bdd 100644
--- a/src/dawn_native/Surface.cpp
+++ b/src/dawn_native/Surface.cpp
@@ -50,12 +50,12 @@
 #if defined(DAWN_ENABLE_BACKEND_METAL)
         const SurfaceDescriptorFromMetalLayer* metalDesc = nullptr;
         FindInChain(descriptor->nextInChain, &metalDesc);
-        if (!metalDesc) {
-            return DAWN_VALIDATION_ERROR("Unsupported sType");
-        }
-        // Check that the layer is a CAMetalLayer (or a derived class).
-        if (!InheritsFromCAMetalLayer(metalDesc->layer)) {
-            return DAWN_VALIDATION_ERROR("layer must be a CAMetalLayer");
+        if (metalDesc) {
+            // Check that the layer is a CAMetalLayer (or a derived class).
+            if (!InheritsFromCAMetalLayer(metalDesc->layer)) {
+                return DAWN_VALIDATION_ERROR("layer must be a CAMetalLayer");
+            }
+            return {};
         }
 #endif  // defined(DAWN_ENABLE_BACKEND_METAL)
 
@@ -94,32 +94,31 @@
             }
             return {};
         }
-        return DAWN_VALIDATION_ERROR("Unsupported sType");
 #endif  // defined(DAWN_PLATFORM_WINDOWS)
 
 #if defined(DAWN_USE_X11)
         const SurfaceDescriptorFromXlib* xDesc = nullptr;
         FindInChain(descriptor->nextInChain, &xDesc);
-        if (!xDesc) {
-            return DAWN_VALIDATION_ERROR("Unsupported sType");
-        }
-        // Check the validity of the window by calling a getter function on the window that
-        // returns a status code. If the window is bad the call return a status of zero. We
-        // need to set a temporary X11 error handler while doing this because the default
-        // X11 error handler exits the program on any error.
-        XErrorHandler oldErrorHandler =
-            XSetErrorHandler([](Display*, XErrorEvent*) { return 0; });
-        XWindowAttributes attributes;
-        int status = XGetWindowAttributes(reinterpret_cast<Display*>(xDesc->display),
-                                          xDesc->window, &attributes);
-        XSetErrorHandler(oldErrorHandler);
+        if (xDesc) {
+            // Check the validity of the window by calling a getter function on the window that
+            // returns a status code. If the window is bad the call return a status of zero. We
+            // need to set a temporary X11 error handler while doing this because the default
+            // X11 error handler exits the program on any error.
+            XErrorHandler oldErrorHandler =
+                XSetErrorHandler([](Display*, XErrorEvent*) { return 0; });
+            XWindowAttributes attributes;
+            int status = XGetWindowAttributes(reinterpret_cast<Display*>(xDesc->display),
+                                              xDesc->window, &attributes);
+            XSetErrorHandler(oldErrorHandler);
 
-        if (status == 0) {
-            return DAWN_VALIDATION_ERROR("Invalid X Window");
+            if (status == 0) {
+                return DAWN_VALIDATION_ERROR("Invalid X Window");
+            }
+            return {};
         }
 #endif  // defined(DAWN_USE_X11)
 
-        return {};
+        return DAWN_VALIDATION_ERROR("Unsupported sType");
     }
 
     Surface::Surface(InstanceBase* instance, const SurfaceDescriptor* descriptor)