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>
This commit is contained in:
Carl Woffenden 2021-01-13 22:09:24 +00:00 committed by Commit Bot service account
parent 313ae9e87f
commit 90c266de5a
1 changed files with 12 additions and 4 deletions

View File

@ -85,10 +85,16 @@ const char kUsage[] = R"(Usage: tint [options] <input-file>
Affects AST dumping, and text-based output languages. Affects AST dumping, and text-based output languages.
-h -- This help text)"; -h -- This help text)";
#if _MSC_VER
#pragma warning(disable : 4068; suppress : 4100)
#endif
#pragma clang diagnostic push #pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-parameter" #pragma clang diagnostic ignored "-Wunused-parameter"
Format parse_format(const std::string& fmt) { Format parse_format(const std::string& fmt) {
#pragma clang diagnostic pop #pragma clang diagnostic pop
#if _MSC_VER
#pragma warning(default : 4068)
#endif
#if TINT_BUILD_SPV_WRITER #if TINT_BUILD_SPV_WRITER
if (fmt == "spirv") if (fmt == "spirv")
@ -128,10 +134,16 @@ bool ends_with(const std::string& input, const std::string& suffix) {
/// @param filename the filename to inspect /// @param filename the filename to inspect
/// @returns the inferred format for the filename suffix /// @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 push
#pragma clang diagnostic ignored "-Wunused-parameter" #pragma clang diagnostic ignored "-Wunused-parameter"
Format infer_format(const std::string& filename) { Format infer_format(const std::string& filename) {
#pragma clang diagnostic pop #pragma clang diagnostic pop
#if _MSC_VER
#pragma warning(default : 4068)
#endif
#if TINT_BUILD_SPV_WRITER #if TINT_BUILD_SPV_WRITER
if (ends_with(filename, ".spv")) { if (ends_with(filename, ".spv")) {
@ -260,12 +272,8 @@ bool ParseArgs(const std::vector<std::string>& args, Options* opts) {
/// writes error messages to the standard error stream and returns false. /// writes error messages to the standard error stream and returns false.
/// Assumes the size of a `T` object is divisible by its required alignment. /// Assumes the size of a `T` object is divisible by its required alignment.
/// @returns true if we successfully read the file. /// @returns true if we successfully read the file.
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-template"
template <typename T> template <typename T>
bool ReadFile(const std::string& input_file, std::vector<T>* buffer) { bool ReadFile(const std::string& input_file, std::vector<T>* buffer) {
#pragma clang diagnostic pop
if (!buffer) { if (!buffer) {
std::cerr << "The buffer pointer was null" << std::endl; std::cerr << "The buffer pointer was null" << std::endl;
return false; return false;