Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 1 | // Copyright 2014 the V8 project authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef V8_BASE_COMPILER_SPECIFIC_H_ |
| 6 | #define V8_BASE_COMPILER_SPECIFIC_H_ |
| 7 | |
| 8 | #include "include/v8config.h" |
| 9 | |
| 10 | // Annotate a variable indicating it's ok if the variable is not used. |
| 11 | // (Typically used to silence a compiler warning when the assignment |
| 12 | // is important for some other reason.) |
| 13 | // Use like: |
| 14 | // int x ALLOW_UNUSED = ...; |
| 15 | #if V8_HAS_ATTRIBUTE_UNUSED |
| 16 | #define ALLOW_UNUSED __attribute__((unused)) |
| 17 | #else |
| 18 | #define ALLOW_UNUSED |
| 19 | #endif |
| 20 | |
| 21 | |
| 22 | // Annotate a virtual method indicating it must be overriding a virtual |
| 23 | // method in the parent class. |
| 24 | // Use like: |
| 25 | // virtual void bar() OVERRIDE; |
| 26 | #if V8_HAS_CXX11_OVERRIDE |
| 27 | #define OVERRIDE override |
| 28 | #else |
| 29 | #define OVERRIDE /* NOT SUPPORTED */ |
| 30 | #endif |
| 31 | |
| 32 | |
| 33 | // Annotate a virtual method indicating that subclasses must not override it, |
| 34 | // or annotate a class to indicate that it cannot be subclassed. |
| 35 | // Use like: |
| 36 | // class B FINAL : public A {}; |
| 37 | // virtual void bar() FINAL; |
| 38 | #if V8_HAS_CXX11_FINAL |
| 39 | #define FINAL final |
| 40 | #elif V8_HAS___FINAL |
| 41 | #define FINAL __final |
| 42 | #elif V8_HAS_SEALED |
| 43 | #define FINAL sealed |
| 44 | #else |
| 45 | #define FINAL /* NOT SUPPORTED */ |
| 46 | #endif |
| 47 | |
| 48 | |
| 49 | // Annotate a function indicating the caller must examine the return value. |
| 50 | // Use like: |
| 51 | // int foo() WARN_UNUSED_RESULT; |
| 52 | #if V8_HAS_ATTRIBUTE_WARN_UNUSED_RESULT |
| 53 | #define WARN_UNUSED_RESULT __attribute__((warn_unused_result)) |
| 54 | #else |
| 55 | #define WARN_UNUSED_RESULT /* NOT SUPPORTED */ |
| 56 | #endif |
| 57 | |
| 58 | #endif // V8_BASE_COMPILER_SPECIFIC_H_ |