From f2bef86c4d6d516bef546572f62fa0945969613e Mon Sep 17 00:00:00 2001 From: Jeff Walden Date: Thu, 21 Mar 2013 18:26:06 -0700 Subject: [PATCH] Bug 851237 - Mark the static-assert typedef with an unused attribute so it doesn't trigger compiler warnings. r=dholbert --HG-- extra : rebase_source : 20ad6cd988f2cf5ddedfbb7dd99e368b96c2242a --- mfbt/Assertions.h | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/mfbt/Assertions.h b/mfbt/Assertions.h index 6b973627cba1..8942ddd5b1d4 100644 --- a/mfbt/Assertions.h +++ b/mfbt/Assertions.h @@ -76,6 +76,16 @@ # endif #endif #ifndef MOZ_STATIC_ASSERT + /* + * Some of the definitions below create an otherwise-unused typedef. This + * triggers compiler warnings with some versions of gcc, so mark the typedefs + * as permissibly-unused to disable the warnings. + */ +# if defined(__GNUC__) +# define MOZ_STATIC_ASSERT_UNUSED_ATTRIBUTE __attribute__((unused)) +# else +# define MOZ_STATIC_ASSERT_UNUSED_ATTRIBUTE /* nothing */ +# endif # define MOZ_STATIC_ASSERT_GLUE1(x, y) x##y # define MOZ_STATIC_ASSERT_GLUE(x, y) MOZ_STATIC_ASSERT_GLUE1(x, y) # if defined(__SUNPRO_CC) @@ -108,10 +118,10 @@ * code. */ # define MOZ_STATIC_ASSERT(cond, reason) \ - typedef int MOZ_STATIC_ASSERT_GLUE(moz_static_assert, __COUNTER__)[(cond) ? 1 : -1] + typedef int MOZ_STATIC_ASSERT_GLUE(moz_static_assert, __COUNTER__)[(cond) ? 1 : -1] MOZ_STATIC_ASSERT_UNUSED_ATTRIBUTE # else # define MOZ_STATIC_ASSERT(cond, reason) \ - extern void MOZ_STATIC_ASSERT_GLUE(moz_static_assert, __LINE__)(int arg[(cond) ? 1 : -1]) + extern void MOZ_STATIC_ASSERT_GLUE(moz_static_assert, __LINE__)(int arg[(cond) ? 1 : -1]) MOZ_STATIC_ASSERT_UNUSED_ATTRIBUTE # endif #endif