Disable/avoid some warnings.
Implement DAWN_DECLARE_UNUSED macro to avoid -Wunneeded-internal-declaration
warning.
Change-Id: I4d087d2b09b74e35ba7ea69533df2c5adef4ef82
Reviewed-on: https://dawn-review.googlesource.com/c/2943
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Stephen White <senorblanco@chromium.org>
diff --git a/generator/templates/dawn_wire/WireCmd.cpp b/generator/templates/dawn_wire/WireCmd.cpp
index 99f1a25..2464bf0 100644
--- a/generator/templates/dawn_wire/WireCmd.cpp
+++ b/generator/templates/dawn_wire/WireCmd.cpp
@@ -110,7 +110,7 @@
};
//* Returns the required transfer size for `record` in addition to the transfer structure.
- size_t {{name}}GetExtraRequiredSize(const {{name}}& record) {
+ DAWN_DECLARE_UNUSED size_t {{name}}GetExtraRequiredSize(const {{name}}& record) {
DAWN_UNUSED(record);
size_t result = 0;
diff --git a/src/common/Compiler.h b/src/common/Compiler.h
index 72a8c60..06b38ab 100644
--- a/src/common/Compiler.h
+++ b/src/common/Compiler.h
@@ -24,6 +24,9 @@
// (resp. false) to help it generate code that leads to better branch prediction.
// - DAWN_UNUSED(EXPR): Prevents unused variable/expression warnings on EXPR.
// - DAWN_UNUSED_FUNC(FUNC): Prevents unused function warnings on FUNC.
+// - DAWN_DECLARE_UNUSED: Prevents unused function warnings a subsequent declaration.
+// Both DAWN_UNUSED_FUNC and DAWN_DECLARE_UNUSED may be necessary, e.g. to suppress clang's
+// unneeded-internal-declaration warning.
// Clang and GCC, check for __clang__ too to catch clang-cl masquarading as MSVC
#if defined(__GNUC__) || defined(__clang__)
@@ -57,6 +60,8 @@
# define DAWN_NO_DISCARD [[nodiscard]]
# endif
+# define DAWN_DECLARE_UNUSED __attribute__((unused))
+
// MSVC
#elif defined(_MSC_VER)
# define DAWN_COMPILER_MSVC
@@ -71,6 +76,8 @@
# define DAWN_NO_DISCARD [[nodiscard]]
# endif
+# define DAWN_DECLARE_UNUSED
+
#else
# error "Unsupported compiler"
#endif
diff --git a/third_party/BUILD.gn b/third_party/BUILD.gn
index c87f64c..070a5c9 100644
--- a/third_party/BUILD.gn
+++ b/third_party/BUILD.gn
@@ -58,6 +58,9 @@
"-Wno-return-type",
"-Wno-sign-compare",
]
+ } else {
+ # Disable "not all control paths return a value" warning.
+ cflags_cc = [ "/wd4715" ]
}
sources = [
@@ -211,7 +214,10 @@
# nonstandard extension, function/data pointer conversion in expression
cflags_c = [ "/wd4152" ]
} else {
- cflags_c = [ "-Wno-sign-compare" ]
+ cflags_c = [
+ "-Wno-sign-compare",
+ "-Wno-missing-field-initializers",
+ ]
}
sources = [