From 90c266de5a0add0d2bf7e4da7501674966665262 Mon Sep 17 00:00:00 2001 From: Carl Woffenden Date: Wed, 13 Jan 2021 22:09:24 +0000 Subject: [PATCH] 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 Reviewed-by: dan sinclair --- samples/main.cc | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/samples/main.cc b/samples/main.cc index 21bf81199d..862ebd998a 100644 --- a/samples/main.cc +++ b/samples/main.cc @@ -85,10 +85,16 @@ const char kUsage[] = R"(Usage: tint [options] 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 @@ bool ends_with(const std::string& input, const std::string& suffix) { /// @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 @@ bool ParseArgs(const std::vector& args, Options* opts) { /// 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 bool ReadFile(const std::string& input_file, std::vector* buffer) { -#pragma clang diagnostic pop - if (!buffer) { std::cerr << "The buffer pointer was null" << std::endl; return false;