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
This commit is contained in:
Jeff Walden 2013-03-21 18:26:06 -07:00
Родитель 15a126ec68
Коммит f2bef86c4d
1 изменённых файлов: 12 добавлений и 2 удалений

Просмотреть файл

@ -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