Bug 1324093 - Part 3.5: Add MOZ_MAYBE_UNUSED to mfbt/Attributes.h. r=froydnj
authorDavid Major <dmajor@mozilla.com>
Wed, 18 Jan 2017 09:37:54 +1300
changeset 329694 d319245c16de06af8e614e9bf1404fa4f390a385
parent 329693 f82548e0df704c91cf06caee7974153a062e4043
child 329695 b6e50de104a6ea7cf0085c8de4f37237b8b4646f
push id85784
push userdmajor@mozilla.com
push dateTue, 17 Jan 2017 21:11:06 +0000
treeherdermozilla-inbound@b6e50de104a6 [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: Ef1nkRipaDg
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.