Preliminary fixes for upgrading the MSVC toolchain

Fixes / suppresses a couple warnings raised by the updated MSVC and
silences all C++17 deprecation warnings since we can only fix them after
we update to use C++17.

Bug: dawn:824
Change-Id: I047985f26244ed3a42c73740617aee15546ca9dd
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/75072
Auto-Submit: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Loko Kung <lokokung@google.com>
Commit-Queue: Loko Kung <lokokung@google.com>
diff --git a/src/common/BUILD.gn b/src/common/BUILD.gn
index 9347674..9fe4fe7 100644
--- a/src/common/BUILD.gn
+++ b/src/common/BUILD.gn
@@ -146,6 +146,17 @@
     # Dawn extends wgpu enums with internal enums.
     # MSVC considers these invalid switch values. crbug.com/dawn/397.
     cflags += [ "/wd4063" ]
+
+    # MSVC things that a switch over all the enum values of an enum class is
+    # not sufficient to cover all control paths. Turn off this warning so that
+    # the respective clang warning tells us where to add switch cases
+    # (otherwise we have to add default: UNREACHABLE() that silences clang too)
+    cflags += [ "/wd4715" ]
+
+    # MSVC emits warnings when using constructs deprecated in C++17. Silence
+    # them until they are fixed.
+    # TODO(dawn:824): Fix all uses of C++ features deprecated in C++17.
+    defines += [ "_SILENCE_ALL_CXX17_DEPRECATION_WARNINGS" ]
     if (dawn_is_winuwp) {
       # /ZW makes sure we don't add calls that are forbidden in UWP.
       # and /EHsc is required to be used in combination with it,
diff --git a/src/tests/unittests/wire/WireAdapterTests.cpp b/src/tests/unittests/wire/WireAdapterTests.cpp
index 48b0a7f..797af9a 100644
--- a/src/tests/unittests/wire/WireAdapterTests.cpp
+++ b/src/tests/unittests/wire/WireAdapterTests.cpp
@@ -193,7 +193,7 @@
                         for (wgpu::FeatureName feature : fakeFeatures) {
                             *(features++) = static_cast<WGPUFeatureName>(feature);
                         }
-                        return fakeFeatures.size();
+                        return static_cast<uint32_t>(fakeFeatures.size());
                     })));
 
                 api.CallAdapterRequestDeviceCallback(apiAdapter, WGPURequestDeviceStatus_Success,
@@ -259,7 +259,7 @@
                         for (wgpu::FeatureName feature : fakeFeatures) {
                             *(features++) = static_cast<WGPUFeatureName>(feature);
                         }
-                        return fakeFeatures.size();
+                        return static_cast<uint32_t>(fakeFeatures.size());
                     })));
 
                 // The device was actually created, but the wire didn't support its features.
diff --git a/src/tests/unittests/wire/WireInstanceTests.cpp b/src/tests/unittests/wire/WireInstanceTests.cpp
index 6ef0a4c..f9a976a 100644
--- a/src/tests/unittests/wire/WireInstanceTests.cpp
+++ b/src/tests/unittests/wire/WireInstanceTests.cpp
@@ -138,7 +138,7 @@
                         for (wgpu::FeatureName feature : fakeFeatures) {
                             *(features++) = static_cast<WGPUFeatureName>(feature);
                         }
-                        return fakeFeatures.size();
+                        return static_cast<uint32_t>(fakeFeatures.size());
                     })));
                 api.CallInstanceRequestAdapterCallback(
                     apiInstance, WGPURequestAdapterStatus_Success, apiAdapter, nullptr);
@@ -217,7 +217,7 @@
                         for (wgpu::FeatureName feature : fakeFeatures) {
                             *(features++) = static_cast<WGPUFeatureName>(feature);
                         }
-                        return fakeFeatures.size();
+                        return static_cast<uint32_t>(fakeFeatures.size());
                     })));
                 api.CallInstanceRequestAdapterCallback(
                     apiInstance, WGPURequestAdapterStatus_Success, apiAdapter, nullptr);
diff --git a/src/tests/white_box/EGLImageWrappingTests.cpp b/src/tests/white_box/EGLImageWrappingTests.cpp
index eb88a7c..7d7d71c 100644
--- a/src/tests/white_box/EGLImageWrappingTests.cpp
+++ b/src/tests/white_box/EGLImageWrappingTests.cpp
@@ -135,7 +135,7 @@
         gl.BindTexture(GL_TEXTURE_2D, tex);
         gl.TexImage2D(GL_TEXTURE_2D, 0, internalFormat, width, height, 0, format, type, data);
         EGLAttrib attribs[1] = {EGL_NONE};
-        EGLClientBuffer buffer = reinterpret_cast<EGLClientBuffer>(tex);
+        EGLClientBuffer buffer = reinterpret_cast<EGLClientBuffer>(static_cast<intptr_t>(tex));
         EGLDisplay dpy = egl.GetCurrentDisplay();
         EGLContext ctx = egl.GetCurrentContext();
         EGLImage eglImage = egl.CreateImage(dpy, ctx, EGL_GL_TEXTURE_2D, buffer, attribs);