~mozillateam/mozilla-build-system/beta

« back to all changes in this revision

Viewing changes to mfbt/Attributes.h

  • Committer: Chris Coulson
  • Date: 2012-11-12 18:20:56 UTC
  • Revision ID: chris.coulson@canonical.com-20121112182056-3r77w3hnptjguvr5
Don't include mfbt in the build system, so that the mfbt headers from the SDK are used

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2
 
/* This Source Code Form is subject to the terms of the Mozilla Public
3
 
 * License, v. 2.0. If a copy of the MPL was not distributed with this
4
 
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5
 
 
6
 
/* Implementations of various class and method modifier attributes. */
7
 
 
8
 
#ifndef mozilla_Attributes_h_
9
 
#define mozilla_Attributes_h_
10
 
 
11
 
/*
12
 
 * This header does not include any other headers so that it can be included by
13
 
 * code that is (only currently) mfbt-incompatible.
14
 
 */
15
 
 
16
 
/*
17
 
 * MOZ_INLINE is a macro which expands to tell the compiler that the method
18
 
 * decorated with it should be inlined.  This macro is usable from C and C++
19
 
 * code, even though C89 does not support the |inline| keyword.  The compiler
20
 
 * may ignore this directive if it chooses.
21
 
 */
22
 
#if defined(__cplusplus)
23
 
#  define MOZ_INLINE            inline
24
 
#elif defined(_MSC_VER)
25
 
#  define MOZ_INLINE            __inline
26
 
#elif defined(__GNUC__)
27
 
#  define MOZ_INLINE            __inline__
28
 
#else
29
 
#  define MOZ_INLINE            inline
30
 
#endif
31
 
 
32
 
/*
33
 
 * MOZ_ALWAYS_INLINE is a macro which expands to tell the compiler that the
34
 
 * method decorated with it must be inlined, even if the compiler thinks
35
 
 * otherwise.  This is only a (much) stronger version of the MOZ_INLINE hint:
36
 
 * compilers are not guaranteed to respect it (although they're much more likely
37
 
 * to do so).
38
 
 */
39
 
#if defined(DEBUG)
40
 
#  define MOZ_ALWAYS_INLINE     MOZ_INLINE
41
 
#elif defined(_MSC_VER)
42
 
#  define MOZ_ALWAYS_INLINE     __forceinline
43
 
#elif defined(__GNUC__)
44
 
#  define MOZ_ALWAYS_INLINE     __attribute__((always_inline)) MOZ_INLINE
45
 
#else
46
 
#  define MOZ_ALWAYS_INLINE     MOZ_INLINE
47
 
#endif
48
 
 
49
 
/*
50
 
 * g++ requires -std=c++0x or -std=gnu++0x to support C++11 functionality
51
 
 * without warnings (functionality used by the macros below).  These modes are
52
 
 * detectable by checking whether __GXX_EXPERIMENTAL_CXX0X__ is defined or, more
53
 
 * standardly, by checking whether __cplusplus has a C++11 or greater value.
54
 
 * Current versions of g++ do not correctly set __cplusplus, so we check both
55
 
 * for forward compatibility.
56
 
 */
57
 
#if defined(__clang__)
58
 
   /*
59
 
    * Per Clang documentation, "Note that marketing version numbers should not
60
 
    * be used to check for language features, as different vendors use different
61
 
    * numbering schemes. Instead, use the feature checking macros."
62
 
    */
63
 
#  ifndef __has_extension
64
 
#    define __has_extension __has_feature /* compatibility, for older versions of clang */
65
 
#  endif
66
 
#  if __has_extension(cxx_deleted_functions)
67
 
#    define MOZ_HAVE_CXX11_DELETE
68
 
#  endif
69
 
#  if __has_extension(cxx_override_control)
70
 
#    define MOZ_HAVE_CXX11_OVERRIDE
71
 
#    define MOZ_HAVE_CXX11_FINAL         final
72
 
#  endif
73
 
#  if __has_extension(cxx_strong_enums)
74
 
#    define MOZ_HAVE_CXX11_ENUM_TYPE
75
 
#    define MOZ_HAVE_CXX11_STRONG_ENUMS
76
 
#  endif
77
 
#  if __has_attribute(noinline)
78
 
#    define MOZ_HAVE_NEVER_INLINE        __attribute__((noinline))
79
 
#  endif
80
 
#  if __has_attribute(noreturn)
81
 
#    define MOZ_HAVE_NORETURN            __attribute__((noreturn))
82
 
#  endif
83
 
#elif defined(__GNUC__)
84
 
#  if defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L
85
 
#    if __GNUC__ > 4
86
 
#      define MOZ_HAVE_CXX11_DELETE
87
 
#      define MOZ_HAVE_CXX11_OVERRIDE
88
 
#      define MOZ_HAVE_CXX11_FINAL       final
89
 
#    elif __GNUC__ == 4
90
 
#      if __GNUC_MINOR__ >= 7
91
 
#        define MOZ_HAVE_CXX11_OVERRIDE
92
 
#        define MOZ_HAVE_CXX11_FINAL     final
93
 
#      endif
94
 
#      if __GNUC_MINOR__ >= 4
95
 
#        define MOZ_HAVE_CXX11_DELETE
96
 
#        define MOZ_HAVE_CXX11_ENUM_TYPE
97
 
#        define MOZ_HAVE_CXX11_STRONG_ENUMS
98
 
#      endif
99
 
#    endif
100
 
#  else
101
 
     /* __final is a non-C++11 GCC synonym for 'final', per GCC r176655. */
102
 
#    if __GNUC__ > 4
103
 
#      define MOZ_HAVE_CXX11_FINAL       __final
104
 
#    elif __GNUC__ == 4
105
 
#      if __GNUC_MINOR__ >= 7
106
 
#        define MOZ_HAVE_CXX11_FINAL     __final
107
 
#      endif
108
 
#    endif
109
 
#  endif
110
 
#  define MOZ_HAVE_NEVER_INLINE          __attribute__((noinline))
111
 
#  define MOZ_HAVE_NORETURN              __attribute__((noreturn))
112
 
#elif defined(_MSC_VER)
113
 
#  if _MSC_VER >= 1400
114
 
#    define MOZ_HAVE_CXX11_OVERRIDE
115
 
     /* MSVC currently spells "final" as "sealed". */
116
 
#    define MOZ_HAVE_CXX11_FINAL         sealed
117
 
#    define MOZ_HAVE_CXX11_ENUM_TYPE
118
 
#  endif
119
 
#  if _MSC_VER >= 1700
120
 
#    define MOZ_HAVE_CXX11_STRONG_ENUMS
121
 
#  endif
122
 
#  define MOZ_HAVE_NEVER_INLINE          __declspec(noinline)
123
 
#  define MOZ_HAVE_NORETURN              __declspec(noreturn)
124
 
#endif
125
 
 
126
 
/*
127
 
 * MOZ_NEVER_INLINE is a macro which expands to tell the compiler that the
128
 
 * method decorated with it must never be inlined, even if the compiler would
129
 
 * otherwise choose to inline the method.  Compilers aren't absolutely
130
 
 * guaranteed to support this, but most do.
131
 
 */
132
 
#if defined(MOZ_HAVE_NEVER_INLINE)
133
 
#  define MOZ_NEVER_INLINE      MOZ_HAVE_NEVER_INLINE
134
 
#else
135
 
#  define MOZ_NEVER_INLINE      /* no support */
136
 
#endif
137
 
 
138
 
/*
139
 
 * MOZ_NORETURN, specified at the start of a function declaration, indicates
140
 
 * that the given function does not return.  (The function definition does not
141
 
 * need to be annotated.)
142
 
 *
143
 
 *   MOZ_NORETURN void abort(const char* msg);
144
 
 *
145
 
 * This modifier permits the compiler to optimize code assuming a call to such a
146
 
 * function will never return.  It also enables the compiler to avoid spurious
147
 
 * warnings about not initializing variables, or about any other seemingly-dodgy
148
 
 * operations performed after the function returns.
149
 
 *
150
 
 * This modifier does not affect the corresponding function's linking behavior.
151
 
 */
152
 
#if defined(MOZ_HAVE_NORETURN)
153
 
#  define MOZ_NORETURN          MOZ_HAVE_NORETURN
154
 
#else
155
 
#  define MOZ_NORETURN          /* no support */
156
 
#endif
157
 
 
158
 
/*
159
 
 * MOZ_ASAN_BLACKLIST is a macro to tell AddressSanitizer (a compile-time
160
 
 * instrumentation shipped with Clang) to not instrument the annotated function.
161
 
 * Furthermore, it will prevent the compiler from inlining the function because
162
 
 * inlining currently breaks the blacklisting mechanism of AddressSanitizer.
163
 
 */
164
 
#if defined(MOZ_ASAN)
165
 
#  define MOZ_ASAN_BLACKLIST MOZ_NEVER_INLINE __attribute__((no_address_safety_analysis))
166
 
# else
167
 
#  define MOZ_ASAN_BLACKLIST
168
 
#endif
169
 
 
170
 
 
171
 
#ifdef __cplusplus
172
 
 
173
 
/*
174
 
 * MOZ_DELETE, specified immediately prior to the ';' terminating an undefined-
175
 
 * method declaration, attempts to delete that method from the corresponding
176
 
 * class.  An attempt to use the method will always produce an error *at compile
177
 
 * time* (instead of sometimes as late as link time) when this macro can be
178
 
 * implemented.  For example, you can use MOZ_DELETE to produce classes with no
179
 
 * implicit copy constructor or assignment operator:
180
 
 *
181
 
 *   struct NonCopyable
182
 
 *   {
183
 
 *     private:
184
 
 *       NonCopyable(const NonCopyable& other) MOZ_DELETE;
185
 
 *       void operator=(const NonCopyable& other) MOZ_DELETE;
186
 
 *   };
187
 
 *
188
 
 * If MOZ_DELETE can't be implemented for the current compiler, use of the
189
 
 * annotated method will still cause an error, but the error might occur at link
190
 
 * time in some cases rather than at compile time.
191
 
 *
192
 
 * MOZ_DELETE relies on C++11 functionality not universally implemented.  As a
193
 
 * backstop, method declarations using MOZ_DELETE should be private.
194
 
 */
195
 
#if defined(MOZ_HAVE_CXX11_DELETE)
196
 
#  define MOZ_DELETE            = delete
197
 
#else
198
 
#  define MOZ_DELETE            /* no support */
199
 
#endif
200
 
 
201
 
/*
202
 
 * MOZ_OVERRIDE explicitly indicates that a virtual member function in a class
203
 
 * overrides a member function of a base class, rather than potentially being a
204
 
 * new member function.  MOZ_OVERRIDE should be placed immediately before the
205
 
 * ';' terminating the member function's declaration, or before '= 0;' if the
206
 
 * member function is pure.  If the member function is defined in the class
207
 
 * definition, it should appear before the opening brace of the function body.
208
 
 *
209
 
 *   class Base
210
 
 *   {
211
 
 *     public:
212
 
 *       virtual void f() = 0;
213
 
 *   };
214
 
 *   class Derived1 : public Base
215
 
 *   {
216
 
 *     public:
217
 
 *       virtual void f() MOZ_OVERRIDE;
218
 
 *   };
219
 
 *   class Derived2 : public Base
220
 
 *   {
221
 
 *     public:
222
 
 *       virtual void f() MOZ_OVERRIDE = 0;
223
 
 *   };
224
 
 *   class Derived3 : public Base
225
 
 *   {
226
 
 *     public:
227
 
 *       virtual void f() MOZ_OVERRIDE { }
228
 
 *   };
229
 
 *
230
 
 * In compilers supporting C++11 override controls, MOZ_OVERRIDE *requires* that
231
 
 * the function marked with it override a member function of a base class: it
232
 
 * is a compile error if it does not.  Otherwise MOZ_OVERRIDE does not affect
233
 
 * semantics and merely documents the override relationship to the reader (but
234
 
 * of course must still be used correctly to not break C++11 compilers).
235
 
 */
236
 
#if defined(MOZ_HAVE_CXX11_OVERRIDE)
237
 
#  define MOZ_OVERRIDE          override
238
 
#else
239
 
#  define MOZ_OVERRIDE          /* no support */
240
 
#endif
241
 
 
242
 
/*
243
 
 * MOZ_FINAL indicates that some functionality cannot be overridden through
244
 
 * inheritance.  It can be used to annotate either classes/structs or virtual
245
 
 * member functions.
246
 
 *
247
 
 * To annotate a class/struct with MOZ_FINAL, place MOZ_FINAL immediately after
248
 
 * the name of the class, before the list of classes from which it derives (if
249
 
 * any) and before its opening brace.  MOZ_FINAL must not be used to annotate
250
 
 * unnamed classes or structs.  (With some compilers, and with C++11 proper, the
251
 
 * underlying expansion is ambiguous with specifying a class name.)
252
 
 *
253
 
 *   class Base MOZ_FINAL
254
 
 *   {
255
 
 *     public:
256
 
 *       Base();
257
 
 *       ~Base();
258
 
 *       virtual void f() { }
259
 
 *   };
260
 
 *   // This will be an error in some compilers:
261
 
 *   class Derived : public Base
262
 
 *   {
263
 
 *     public:
264
 
 *       ~Derived() { }
265
 
 *   };
266
 
 *
267
 
 * One particularly common reason to specify MOZ_FINAL upon a class is to tell
268
 
 * the compiler that it's not dangerous for it to have a non-virtual destructor
269
 
 * yet have one or more virtual functions, silencing the warning it might emit
270
 
 * in this case.  Suppose Base above weren't annotated with MOZ_FINAL.  Because
271
 
 * ~Base() is non-virtual, an attempt to delete a Derived* through a Base*
272
 
 * wouldn't call ~Derived(), so any cleanup ~Derived() might do wouldn't happen.
273
 
 * (Formally C++ says behavior is undefined, but compilers will likely just call
274
 
 * ~Base() and not ~Derived().)  Specifying MOZ_FINAL tells the compiler that
275
 
 * it's safe for the destructor to be non-virtual.
276
 
 *
277
 
 * In compilers implementing final controls, it is an error to inherit from a
278
 
 * class annotated with MOZ_FINAL.  In other compilers it serves only as
279
 
 * documentation.
280
 
 *
281
 
 * To annotate a virtual member function with MOZ_FINAL, place MOZ_FINAL
282
 
 * immediately before the ';' terminating the member function's declaration, or
283
 
 * before '= 0;' if the member function is pure.  If the member function is
284
 
 * defined in the class definition, it should appear before the opening brace of
285
 
 * the function body.  (This placement is identical to that for MOZ_OVERRIDE.
286
 
 * If both are used, they should appear in the order 'MOZ_FINAL MOZ_OVERRIDE'
287
 
 * for consistency.)
288
 
 *
289
 
 *   class Base
290
 
 *   {
291
 
 *     public:
292
 
 *       virtual void f() MOZ_FINAL;
293
 
 *   };
294
 
 *   class Derived
295
 
 *   {
296
 
 *     public:
297
 
 *       // This will be an error in some compilers:
298
 
 *       virtual void f();
299
 
 *   };
300
 
 *
301
 
 * In compilers implementing final controls, it is an error for a derived class
302
 
 * to override a method annotated with MOZ_FINAL.  In other compilers it serves
303
 
 * only as documentation.
304
 
 */
305
 
#if defined(MOZ_HAVE_CXX11_FINAL)
306
 
#  define MOZ_FINAL             MOZ_HAVE_CXX11_FINAL
307
 
#else
308
 
#  define MOZ_FINAL             /* no support */
309
 
#endif
310
 
 
311
 
/**
312
 
 * MOZ_ENUM_TYPE specifies the underlying numeric type for an enum.  It's
313
 
 * specified by placing MOZ_ENUM_TYPE(type) immediately after the enum name in
314
 
 * its declaration, and before the opening curly brace, like
315
 
 *
316
 
 *   enum MyEnum MOZ_ENUM_TYPE(uint16_t)
317
 
 *   {
318
 
 *     A,
319
 
 *     B = 7,
320
 
 *     C
321
 
 *   };
322
 
 *
323
 
 * In supporting compilers, the macro will expand to ": uint16_t".  The
324
 
 * compiler will allocate exactly two bytes for MyEnum, and will require all
325
 
 * enumerators to have values between 0 and 65535.  (Thus specifying "B =
326
 
 * 100000" instead of "B = 7" would fail to compile.)  In old compilers, the
327
 
 * macro expands to the empty string, and the underlying type is generally
328
 
 * undefined.
329
 
 */
330
 
#ifdef MOZ_HAVE_CXX11_ENUM_TYPE
331
 
#  define MOZ_ENUM_TYPE(type)   : type
332
 
#else
333
 
#  define MOZ_ENUM_TYPE(type)   /* no support */
334
 
#endif
335
 
 
336
 
/**
337
 
 * MOZ_BEGIN_ENUM_CLASS and MOZ_END_ENUM_CLASS provide access to the
338
 
 * strongly-typed enumeration feature of C++11 ("enum class").  If supported
339
 
 * by the compiler, an enum defined using these macros will not be implicitly
340
 
 * converted to any other type, and its enumerators will be scoped using the
341
 
 * enumeration name.  Place MOZ_BEGIN_ENUM_CLASS(EnumName, type) in place of
342
 
 * "enum EnumName {", and MOZ_END_ENUM_CLASS(EnumName) in place of the closing
343
 
 * "};".  For example,
344
 
 *
345
 
 *   MOZ_BEGIN_ENUM_CLASS(Enum, int32_t)
346
 
 *     A, B = 6
347
 
 *   MOZ_END_ENUM_CLASS(Enum)
348
 
 *
349
 
 * This will make "Enum::A" and "Enum::B" appear in the global scope, but "A"
350
 
 * and "B" will not.  In compilers that support C++11 strongly-typed
351
 
 * enumerations, implicit conversions of Enum values to numeric types will
352
 
 * fail.  In other compilers, Enum itself will actually be defined as a class,
353
 
 * and some implicit conversions will fail while others will succeed.
354
 
 *
355
 
 * The type argument specifies the underlying type for the enum where
356
 
 * supported, as with MOZ_ENUM_TYPE().  For simplicity, it is currently
357
 
 * mandatory.  As with MOZ_ENUM_TYPE(), it will do nothing on compilers that do
358
 
 * not support it.
359
 
 */
360
 
#if defined(MOZ_HAVE_CXX11_STRONG_ENUMS)
361
 
  /* All compilers that support strong enums also support an explicit
362
 
   * underlying type, so no extra check is needed */
363
 
#  define MOZ_BEGIN_ENUM_CLASS(Name, type) enum class Name : type {
364
 
#  define MOZ_END_ENUM_CLASS(Name)         };
365
 
#else
366
 
   /**
367
 
    * We need Name to both name a type, and scope the provided enumerator
368
 
    * names.  Namespaces and classes both provide scoping, but namespaces
369
 
    * aren't types, so we need to use a class that wraps the enum values.  We
370
 
    * have an implicit conversion from the inner enum type to the class, so
371
 
    * statements like
372
 
    *
373
 
    *   Enum x = Enum::A;
374
 
    *
375
 
    * will still work.  We need to define an implicit conversion from the class
376
 
    * to the inner enum as well, so that (for instance) switch statements will
377
 
    * work.  This means that the class can be implicitly converted to a numeric
378
 
    * value as well via the enum type, since C++ allows an implicit
379
 
    * user-defined conversion followed by a standard conversion to still be
380
 
    * implicit.
381
 
    *
382
 
    * We have an explicit constructor from int defined, so that casts like
383
 
    * (Enum)7 will still work.  We also have a zero-argument constructor with
384
 
    * no arguments, so declaration without initialization (like "Enum foo;")
385
 
    * will work.
386
 
    *
387
 
    * Additionally, we'll delete as many operators as possible for the inner
388
 
    * enum type, so statements like this will still fail:
389
 
    *
390
 
    *   f(5 + Enum::B); // deleted operator+
391
 
    *
392
 
    * But we can't prevent things like this, because C++ doesn't allow
393
 
    * overriding conversions or assignment operators for enums:
394
 
    *
395
 
    *   int x = Enum::A;
396
 
    *   int f()
397
 
    *   {
398
 
    *     return Enum::A;
399
 
    *   }
400
 
    */
401
 
#  define MOZ_BEGIN_ENUM_CLASS(Name, type) \
402
 
     class Name \
403
 
     { \
404
 
       public: \
405
 
         enum Enum MOZ_ENUM_TYPE(type) \
406
 
         {
407
 
#  define MOZ_END_ENUM_CLASS(Name) \
408
 
         }; \
409
 
         Name() {} \
410
 
         Name(Enum aEnum) : mEnum(aEnum) {} \
411
 
         explicit Name(int num) : mEnum((Enum)num) {} \
412
 
         operator Enum() const { return mEnum; } \
413
 
       private: \
414
 
         Enum mEnum; \
415
 
     }; \
416
 
     inline int operator+(const int&, const Name::Enum&) MOZ_DELETE; \
417
 
     inline int operator+(const Name::Enum&, const int&) MOZ_DELETE; \
418
 
     inline int operator-(const int&, const Name::Enum&) MOZ_DELETE; \
419
 
     inline int operator-(const Name::Enum&, const int&) MOZ_DELETE; \
420
 
     inline int operator*(const int&, const Name::Enum&) MOZ_DELETE; \
421
 
     inline int operator*(const Name::Enum&, const int&) MOZ_DELETE; \
422
 
     inline int operator/(const int&, const Name::Enum&) MOZ_DELETE; \
423
 
     inline int operator/(const Name::Enum&, const int&) MOZ_DELETE; \
424
 
     inline int operator%(const int&, const Name::Enum&) MOZ_DELETE; \
425
 
     inline int operator%(const Name::Enum&, const int&) MOZ_DELETE; \
426
 
     inline int operator+(const Name::Enum&) MOZ_DELETE; \
427
 
     inline int operator-(const Name::Enum&) MOZ_DELETE; \
428
 
     inline int& operator++(Name::Enum&) MOZ_DELETE; \
429
 
     inline int operator++(Name::Enum&, int) MOZ_DELETE; \
430
 
     inline int& operator--(Name::Enum&) MOZ_DELETE; \
431
 
     inline int operator--(Name::Enum&, int) MOZ_DELETE; \
432
 
     inline bool operator==(const int&, const Name::Enum&) MOZ_DELETE; \
433
 
     inline bool operator==(const Name::Enum&, const int&) MOZ_DELETE; \
434
 
     inline bool operator!=(const int&, const Name::Enum&) MOZ_DELETE; \
435
 
     inline bool operator!=(const Name::Enum&, const int&) MOZ_DELETE; \
436
 
     inline bool operator>(const int&, const Name::Enum&) MOZ_DELETE; \
437
 
     inline bool operator>(const Name::Enum&, const int&) MOZ_DELETE; \
438
 
     inline bool operator<(const int&, const Name::Enum&) MOZ_DELETE; \
439
 
     inline bool operator<(const Name::Enum&, const int&) MOZ_DELETE; \
440
 
     inline bool operator>=(const int&, const Name::Enum&) MOZ_DELETE; \
441
 
     inline bool operator>=(const Name::Enum&, const int&) MOZ_DELETE; \
442
 
     inline bool operator<=(const int&, const Name::Enum&) MOZ_DELETE; \
443
 
     inline bool operator<=(const Name::Enum&, const int&) MOZ_DELETE; \
444
 
     inline bool operator!(const Name::Enum&) MOZ_DELETE; \
445
 
     inline bool operator&&(const bool&, const Name::Enum&) MOZ_DELETE; \
446
 
     inline bool operator&&(const Name::Enum&, const bool&) MOZ_DELETE; \
447
 
     inline bool operator||(const bool&, const Name::Enum&) MOZ_DELETE; \
448
 
     inline bool operator||(const Name::Enum&, const bool&) MOZ_DELETE; \
449
 
     inline int operator~(const Name::Enum&) MOZ_DELETE; \
450
 
     inline int operator&(const int&, const Name::Enum&) MOZ_DELETE; \
451
 
     inline int operator&(const Name::Enum&, const int&) MOZ_DELETE; \
452
 
     inline int operator|(const int&, const Name::Enum&) MOZ_DELETE; \
453
 
     inline int operator|(const Name::Enum&, const int&) MOZ_DELETE; \
454
 
     inline int operator^(const int&, const Name::Enum&) MOZ_DELETE; \
455
 
     inline int operator^(const Name::Enum&, const int&) MOZ_DELETE; \
456
 
     inline int operator<<(const int&, const Name::Enum&) MOZ_DELETE; \
457
 
     inline int operator<<(const Name::Enum&, const int&) MOZ_DELETE; \
458
 
     inline int operator>>(const int&, const Name::Enum&) MOZ_DELETE; \
459
 
     inline int operator>>(const Name::Enum&, const int&) MOZ_DELETE; \
460
 
     inline int& operator+=(int&, const Name::Enum&) MOZ_DELETE; \
461
 
     inline int& operator-=(int&, const Name::Enum&) MOZ_DELETE; \
462
 
     inline int& operator*=(int&, const Name::Enum&) MOZ_DELETE; \
463
 
     inline int& operator/=(int&, const Name::Enum&) MOZ_DELETE; \
464
 
     inline int& operator%=(int&, const Name::Enum&) MOZ_DELETE; \
465
 
     inline int& operator&=(int&, const Name::Enum&) MOZ_DELETE; \
466
 
     inline int& operator|=(int&, const Name::Enum&) MOZ_DELETE; \
467
 
     inline int& operator^=(int&, const Name::Enum&) MOZ_DELETE; \
468
 
     inline int& operator<<=(int&, const Name::Enum&) MOZ_DELETE; \
469
 
     inline int& operator>>=(int&, const Name::Enum&) MOZ_DELETE;
470
 
#endif
471
 
 
472
 
/**
473
 
 * MOZ_WARN_UNUSED_RESULT tells the compiler to emit a warning if a function's
474
 
 * return value is not used by the caller.
475
 
 *
476
 
 * Place this attribute at the very beginning of a function definition. For
477
 
 * example, write
478
 
 *
479
 
 *   MOZ_WARN_UNUSED_RESULT int foo();
480
 
 *
481
 
 * or
482
 
 *
483
 
 *   MOZ_WARN_UNUSED_RESULT int foo() { return 42; }
484
 
 */
485
 
#if defined(__GNUC__) || defined(__clang__)
486
 
#  define MOZ_WARN_UNUSED_RESULT __attribute__ ((warn_unused_result))
487
 
#else
488
 
#  define MOZ_WARN_UNUSED_RESULT
489
 
#endif
490
 
 
491
 
#endif /* __cplusplus */
492
 
 
493
 
#endif  /* mozilla_Attributes_h_ */