~ubuntu-branches/ubuntu/saucy/mozjs17/saucy-proposed

« back to all changes in this revision

Viewing changes to mfbt/Attributes.h

  • Committer: Package Import Robot
  • Author(s): Rico Tzschichholz
  • Date: 2013-05-25 12:24:23 UTC
  • Revision ID: package-import@ubuntu.com-20130525122423-zmxucrhtensw90xy
Tags: upstream-17.0.0
ImportĀ upstreamĀ versionĀ 17.0.0

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