Bug 1652914 - Part 2: Remove unused MOZ_STATIC_ASSERT macro. r=jwalden

Depends on D83736

Differential Revision: https://phabricator.services.mozilla.com/D83737
This commit is contained in:
Chris Peterson 2020-07-17 02:48:36 +00:00
parent fd3e777d61
commit fd6ca4ec31

View File

@ -70,84 +70,6 @@ MOZ_END_EXTERN_C
# include <android/log.h>
#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.
* This can be useful when you make certain assumptions about what must hold for
* optimal, or even correct, behavior. For example, you might assert that the
* size of a struct is a multiple of the target architecture's word size:
*
* struct S { ... };
* // C
* MOZ_STATIC_ASSERT(sizeof(S) % sizeof(size_t) == 0,
* "S should be a multiple of word size for efficiency");
* // C++11
* static_assert(sizeof(S) % sizeof(size_t) == 0,
* "S should be a multiple of word size for efficiency");
*
* This macro can be used in any location where both an extern declaration and a
* typedef could be used.
*/
#ifndef __cplusplus
/*
* 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)
/*
* The Sun Studio C++ compiler is buggy when declaring, inside a function,
* another extern'd function with an array argument whose length contains a
* sizeof, triggering the error message "sizeof expression not accepted as
* size of array parameter". This bug (6688515, not public yet) would hit
* defining moz_static_assert as a function, so we always define an extern
* array for Sun Studio.
*
* We include the line number in the symbol name in a best-effort attempt
* to avoid conflicts (see below).
*/
# define MOZ_STATIC_ASSERT(cond, reason) \
extern char MOZ_STATIC_ASSERT_GLUE(moz_static_assert, \
__LINE__)[(cond) ? 1 : -1]
# elif defined(__COUNTER__)
/*
* If there was no preferred alternative, use a compiler-agnostic version.
*
* Note that the non-__COUNTER__ version has a bug in C++: it can't be used
* in both |extern "C"| and normal C++ in the same translation unit. (Alas
* |extern "C"| isn't allowed in a function.) The only affected compiler
* we really care about is gcc 4.2. For that compiler and others like it,
* we include the line number in the function name to do the best we can to
* avoid conflicts. These should be rare: a conflict would require use of
* MOZ_STATIC_ASSERT on the same line in separate files in the same
* translation unit, *and* the uses would have to be in code with
* different linkage, *and* the first observed use must be in C++-linkage
* code.
*/
# define MOZ_STATIC_ASSERT(cond, reason) \
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_STATIC_ASSERT_UNUSED_ATTRIBUTE
# endif
# define MOZ_STATIC_ASSERT_IF(cond, expr, reason) \
MOZ_STATIC_ASSERT(!(cond) || (expr), reason)
#else
# define MOZ_STATIC_ASSERT_IF(cond, expr, reason) \
static_assert(!(cond) || (expr), reason)
#endif
MOZ_BEGIN_EXTERN_C
/*