Bug 1324093 - Part 3.5: Add MOZ_MAYBE_UNUSED to mfbt/Attributes.h. r=froydnj
☠☠ backed out by c1ccfd6c128e ☠ ☠
authorDavid Major <dmajor@mozilla.com>
Fri, 13 Jan 2017 13:58:23 +1300
changeset 329197 630abb959e06106b586c37bb1f1f55c0dbd620f8
parent 329196 b843a34fdc23d8b7bb630f16903742444c194525
child 329198 7c26d27a3635f692c480a461216ac9fa79dca07d
push id85658
push userdmajor@mozilla.com
push dateFri, 13 Jan 2017 01:00:51 +0000
treeherdermozilla-inbound@7c26d27a3635 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1324093
milestone53.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1324093 - Part 3.5: Add MOZ_MAYBE_UNUSED to mfbt/Attributes.h. r=froydnj MozReview-Commit-ID: KXIaGGJnds3
mfbt/Attributes.h
--- a/mfbt/Attributes.h
+++ b/mfbt/Attributes.h
@@ -270,16 +270,37 @@
  */
 #if defined(__GNUC__) || defined(__clang__)
 #  define MOZ_MUST_USE __attribute__ ((warn_unused_result))
 #else
 #  define MOZ_MUST_USE
 #endif
 
 /**
+ * MOZ_MAYBE_UNUSED suppresses compiler warnings about functions that are
+ * never called (in this build configuration, at least).
+ *
+ * Place this attribute at the very beginning of a function declaration. For
+ * example, write
+ *
+ *   MOZ_MAYBE_UNUSED int foo();
+ *
+ * or
+ *
+ *   MOZ_MAYBE_UNUSED int foo() { return 42; }
+ */
+#if defined(__GNUC__) || defined(__clang__)
+#  define MOZ_MAYBE_UNUSED __attribute__ ((__unused__))
+#elif defined(_MSC_VER)
+#  define MOZ_MAYBE_UNUSED __pragma(warning(suppress:4505))
+#else
+#  define MOZ_MAYBE_UNUSED
+#endif
+
+/**
  * MOZ_FALLTHROUGH is an annotation to suppress compiler warnings about switch
  * cases that fall through without a break or return statement. MOZ_FALLTHROUGH
  * is only needed on cases that have code.
  *
  * MOZ_FALLTHROUGH_ASSERT is an annotation to suppress compiler warnings about
  * switch cases that MOZ_ASSERT(false) (or its alias MOZ_ASSERT_UNREACHABLE) in
  * debug builds, but intentionally fall through in release builds. See comment
  * in Assertions.h for more details.