[node] Move warning disablement to NodeAPI.h, enable MSVC warnings

This avoids GN issues with flag order, where tweaking dependencies can
result in -Wno-extra-semi being overridden by -Wextra-semi. (I didn't
realize previously that we had this wrapper header that could easily
serve this purpose.)

Also:
- Removes disablement of all warnings on MSVC on GN, because it's
  apparently not needed.
- Removes the -isystem flags from GN because they're not necessary
  anymore and they were a slight hack.
- Fixes a few MSVC warnings.

Bug: none
Change-Id: Ibe54da4aff1c2ffa274979756c1c281725ada244
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/245114
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
diff --git a/src/dawn/node/BUILD.gn b/src/dawn/node/BUILD.gn
index cca1fd9..4d7835a 100644
--- a/src/dawn/node/BUILD.gn
+++ b/src/dawn/node/BUILD.gn
@@ -56,38 +56,11 @@
     "$dawn_root/third_party/gn/dxc/build/run_built_binary.py"
 
 config("common_config") {
-  # Add include paths for Node API headers, and handle the fact that they produce many warnings.
-  if (is_win) {
-    # -isystem is not supported (MSVC or clang-cl.exe).
-    include_dirs = [
-      "${dawn_node_addon_api_dir}",
-      "${dawn_node_api_headers_dir}/include",
-    ]
-    if (is_clang) {
-      # Clang (clang-cl.exe). Disable the warnings produced by Node headers.
-      cflags = [
-        "-Wno-extra-semi",
-        "-Wno-extra-semi-stmt",
-        "-Wno-inconsistent-missing-destructor-override",
-        "-Wno-shadow",
-        "-Wno-shadow-field",
-        "-Wno-suggest-destructor-override",
-      ]
-    } else {
-      # MSVC. Just disable most warnings.
-      cflags = [ "/W0" ]
-    }
-  } else {
-    # -isystem should be supported (Clang or GCC).
-    # GN does not have a feature to support -isystem (like CMake's
-    # target_include_directories SYSTEM option), so we set it directly via cflags.
-    # Note this may have slightly weird behavior (e.g. https://crbug.com/41400937).
-    cflags = [
-      "-isystem" + rebase_path(dawn_node_addon_api_dir, root_build_dir),
-      "-isystem" +
-          rebase_path("${dawn_node_api_headers_dir}/include", root_build_dir),
-    ]
-  }
+  # Add include paths for Node API headers.
+  include_dirs = [
+    "${dawn_node_addon_api_dir}",
+    "${dawn_node_api_headers_dir}/include",
+  ]
 }
 
 template("idlgen") {
diff --git a/src/dawn/node/binding/GPUAdapterInfo.cpp b/src/dawn/node/binding/GPUAdapterInfo.cpp
index a1ae894..92d706b 100644
--- a/src/dawn/node/binding/GPUAdapterInfo.cpp
+++ b/src/dawn/node/binding/GPUAdapterInfo.cpp
@@ -27,6 +27,7 @@
 
 #include "src/dawn/node/binding/GPUAdapterInfo.h"
 
+#include <cassert>
 #include <cctype>
 #include <iomanip>
 #include <sstream>
@@ -51,6 +52,8 @@
         case SubgroupMatrixComponentType::I32:
             return interop::GPUSubgroupMatrixComponentType::kI32;
     }
+    assert(false);
+    return interop::GPUSubgroupMatrixComponentType::kF32;
 }
 
 struct GPUSubgroupMatrixConfig : public interop::GPUSubgroupMatrixConfig {
diff --git a/src/dawn/node/binding/GPUDevice.cpp b/src/dawn/node/binding/GPUDevice.cpp
index e190096..60048f9 100644
--- a/src/dawn/node/binding/GPUDevice.cpp
+++ b/src/dawn/node/binding/GPUDevice.cpp
@@ -129,9 +129,10 @@
             // This error type is reserved for when translating an error type from a newer
             // implementation (e.g. the browser added a new error type) to another (e.g.
             // you're using an older version of Emscripten). It shouldn't happen in Dawn.
-            assert(false);
-            return {};
+            break;
     }
+    assert(false);
+    return {};
 }
 
 static std::mutex s_device_to_js_map_mutex_;
diff --git a/src/dawn/node/interop/NodeAPI.h b/src/dawn/node/interop/NodeAPI.h
index 4bd3ae1..e24e673 100644
--- a/src/dawn/node/interop/NodeAPI.h
+++ b/src/dawn/node/interop/NodeAPI.h
@@ -28,9 +28,28 @@
 #ifndef SRC_DAWN_NODE_INTEROP_NODEAPI_H_
 #define SRC_DAWN_NODE_INTEROP_NODEAPI_H_
 
+#include "src/utils/compiler.h"
+
 // Dawn is built with exceptions disabled.
 #define NAPI_DISABLE_CPP_EXCEPTIONS
 
+// Disable warnings produced by Node API header. This is done here rather than in the build file to
+// scope the disablement to just this header (since we can't use -isystem everywhere), and to avoid
+// ordering issues between -Wsomething and -Wno-something.
+#if DAWN_COMPILER_IS_CLANG
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wextra-semi"
+#pragma clang diagnostic ignored "-Wextra-semi-stmt"
+#pragma clang diagnostic ignored "-Winconsistent-missing-destructor-override"
+#pragma clang diagnostic ignored "-Wshadow"
+#pragma clang diagnostic ignored "-Wshadow-field"
+#pragma clang diagnostic ignored "-Wsuggest-destructor-override"
+#endif  // DAWN_COMPILER_IS_CLANG
+
 #include <napi.h>
 
+#if DAWN_COMPILER_IS_CLANG
+#pragma clang diagnostic pop
+#endif  // DAWN_COMPILER_IS_CLANG
+
 #endif  // SRC_DAWN_NODE_INTEROP_NODEAPI_H_