Removed Clang-specific pragmas to build with VS2019
When building for Windows with VS2019 (using 'is_clang=false') with the
default "warnings as errors" this occurs multiple times, halting the
build:
../../third_party/tint/samples/main.cc(88): error C2220:
the following warning is treated as an error
../../third_party/tint/samples/main.cc(88): warning C4068:
unknown pragma 'clang'
Since there's no shared macro for marking potential unused params the
simplest route of a (void) cast is chosen.
Bug: dawn:602
Change-Id: I4e6316df97dc3cd7e45260e2f7471cdd5a9b4b94
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/37700
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
diff --git a/samples/main.cc b/samples/main.cc
index 21bf811..862ebd9 100644
--- a/samples/main.cc
+++ b/samples/main.cc
@@ -85,10 +85,16 @@
Affects AST dumping, and text-based output languages.
-h -- This help text)";
+#if _MSC_VER
+#pragma warning(disable : 4068; suppress : 4100)
+#endif
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-parameter"
Format parse_format(const std::string& fmt) {
#pragma clang diagnostic pop
+#if _MSC_VER
+#pragma warning(default : 4068)
+#endif
#if TINT_BUILD_SPV_WRITER
if (fmt == "spirv")
@@ -128,10 +134,16 @@
/// @param filename the filename to inspect
/// @returns the inferred format for the filename suffix
+#if _MSC_VER
+#pragma warning(disable : 4068; suppress : 4100)
+#endif
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-parameter"
Format infer_format(const std::string& filename) {
#pragma clang diagnostic pop
+#if _MSC_VER
+#pragma warning(default : 4068)
+#endif
#if TINT_BUILD_SPV_WRITER
if (ends_with(filename, ".spv")) {
@@ -260,12 +272,8 @@
/// writes error messages to the standard error stream and returns false.
/// Assumes the size of a `T` object is divisible by its required alignment.
/// @returns true if we successfully read the file.
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wunused-template"
template <typename T>
bool ReadFile(const std::string& input_file, std::vector<T>* buffer) {
-#pragma clang diagnostic pop
-
if (!buffer) {
std::cerr << "The buffer pointer was null" << std::endl;
return false;