From 76e6872498dc503735941cbb3c1e737052fcec24 Mon Sep 17 00:00:00 2001 From: Nigel Tao Date: Fri, 25 Jun 2021 13:50:40 +1000 Subject: [PATCH] Have clang-cl ignore unused-function etc warnings --- cmd/wuffs-c/release.go | 14 ++++++++++++++ release/c/wuffs-unsupported-snapshot.c | 14 ++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/cmd/wuffs-c/release.go b/cmd/wuffs-c/release.go index 4eb0162a..1223c060 100644 --- a/cmd/wuffs-c/release.go +++ b/cmd/wuffs-c/release.go @@ -167,6 +167,9 @@ const grSingleFileGuidance = ` const grPragmaPush = ` // Wuffs' C code is generated automatically, not hand-written. These warnings' // costs outweigh the benefits. +// +// The "elif defined(__clang__)" isn't redundant. While vanilla clang defines +// __GNUC__, clang-cl (which mimics MSVC's cl.exe) does not. #if defined(__GNUC__) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wmissing-field-initializers" @@ -176,6 +179,15 @@ const grPragmaPush = ` #if defined(__cplusplus) #pragma GCC diagnostic ignored "-Wold-style-cast" #endif +#elif defined(__clang__) +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wmissing-field-initializers" +#pragma clang diagnostic ignored "-Wunreachable-code" +#pragma clang diagnostic ignored "-Wunused-function" +#pragma clang diagnostic ignored "-Wunused-parameter" +#if defined(__cplusplus) +#pragma clang diagnostic ignored "-Wold-style-cast" +#endif #endif ` @@ -183,6 +195,8 @@ const grPragmaPush = ` const grPragmaPop = ` #if defined(__GNUC__) #pragma GCC diagnostic pop +#elif defined(__clang__) +#pragma clang diagnostic pop #endif ` diff --git a/release/c/wuffs-unsupported-snapshot.c b/release/c/wuffs-unsupported-snapshot.c index 6bbfa582..e3383c7e 100644 --- a/release/c/wuffs-unsupported-snapshot.c +++ b/release/c/wuffs-unsupported-snapshot.c @@ -10,6 +10,9 @@ // Wuffs' C code is generated automatically, not hand-written. These warnings' // costs outweigh the benefits. +// +// The "elif defined(__clang__)" isn't redundant. While vanilla clang defines +// __GNUC__, clang-cl (which mimics MSVC's cl.exe) does not. #if defined(__GNUC__) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wmissing-field-initializers" @@ -19,6 +22,15 @@ #if defined(__cplusplus) #pragma GCC diagnostic ignored "-Wold-style-cast" #endif +#elif defined(__clang__) +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wmissing-field-initializers" +#pragma clang diagnostic ignored "-Wunreachable-code" +#pragma clang diagnostic ignored "-Wunused-function" +#pragma clang diagnostic ignored "-Wunused-parameter" +#if defined(__cplusplus) +#pragma clang diagnostic ignored "-Wold-style-cast" +#endif #endif // Copyright 2017 The Wuffs Authors. @@ -40546,6 +40558,8 @@ done: #if defined(__GNUC__) #pragma GCC diagnostic pop +#elif defined(__clang__) +#pragma clang diagnostic pop #endif #endif // WUFFS_INCLUDE_GUARD