Bug 1433971 Clean up Assertions.h with respect to Unused Attributes r=froydnj

In Bug 1393538 I renamed MOZ_STATIC_ASSERT_UNUSED_ATTRIBUTE to MOZ_UNUSED_ATTRIBUTE,
moved it out of it's #define depth, and used it in toolkit. I also orphaned a
comment.

This was wrong. MOZ_UNUSED_ATTRIBUTE was basically identical to MOZ_MAYBE_UNUSED
which exists in Attributes.h (because it is an attribute, not an assertion.)

Undo that wrong thing: restore MOZ_STATIC_ASSERT_UNUSED_ATTRIBUTE to the correct
place, have toolkit use the correct macro, and remove MOZ_UNUSED_ATTRIBUTE.

MozReview-Commit-ID: 5BWWsXgbm9i

--HG--
extra : rebase_source : d07156068c877bf57d400bc6a71e115b7f1aef31
This commit is contained in:
Tom Ritter 2018-01-29 11:36:19 -06:00
parent ece90c9c66
commit 41a1a6c9b0
2 changed files with 8 additions and 9 deletions

View File

@ -66,12 +66,6 @@ MOZ_END_EXTERN_C
# include <android/log.h>
#endif
#if defined(__GNUC__)
# define MOZ_UNUSED_ATTRIBUTE __attribute__((unused))
#else
# define MOZ_UNUSED_ATTRIBUTE /* nothing */
#endif
/*
* MOZ_STATIC_ASSERT may be used to assert a condition *at compile time* in C.
* In C++11, static_assert is provided by the compiler to the same effect.
@ -96,6 +90,11 @@ MOZ_END_EXTERN_C
* 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)
@ -128,10 +127,10 @@ MOZ_END_EXTERN_C
* code.
*/
# define MOZ_STATIC_ASSERT(cond, reason) \
typedef int MOZ_STATIC_ASSERT_GLUE(moz_static_assert, __COUNTER__)[(cond) ? 1 : -1] MOZ_UNUSED_ATTRIBUTE
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]) MOZ_UNUSED_ATTRIBUTE
extern void MOZ_STATIC_ASSERT_GLUE(moz_static_assert, __LINE__)(int arg[(cond) ? 1 : -1]) MOZ_STATIC_ASSERT_UNUSED_ATTRIBUTE
# endif
#define MOZ_STATIC_ASSERT_IF(cond, expr, reason) MOZ_STATIC_ASSERT(!(cond) || (expr), reason)

View File

@ -110,7 +110,7 @@ struct Win32Mutex {
// Make sure we release it if we own it.
Unlock();
BOOL rc MOZ_UNUSED_ATTRIBUTE = CloseHandle( mHandle );
BOOL rc MOZ_MAYBE_UNUSED = CloseHandle( mHandle );
#if MOZ_DEBUG_DDE
if ( !rc ) {
printf( "CloseHandle error = 0x%08X\n", (int)GetLastError() );