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 | |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame^] | 10 | // Annotate a typedef or function indicating it's ok if it's not used. |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 11 | // Use like: |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame^] | 12 | // typedef Foo Bar ALLOW_UNUSED_TYPE; |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 13 | #if V8_HAS_ATTRIBUTE_UNUSED |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame^] | 14 | #define ALLOW_UNUSED_TYPE __attribute__((unused)) |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 15 | #else |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame^] | 16 | #define ALLOW_UNUSED_TYPE |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 17 | #endif |
| 18 | |
| 19 | |
| 20 | // Annotate a virtual method indicating it must be overriding a virtual |
| 21 | // method in the parent class. |
| 22 | // Use like: |
| 23 | // virtual void bar() OVERRIDE; |
| 24 | #if V8_HAS_CXX11_OVERRIDE |
| 25 | #define OVERRIDE override |
| 26 | #else |
| 27 | #define OVERRIDE /* NOT SUPPORTED */ |
| 28 | #endif |
| 29 | |
| 30 | |
| 31 | // Annotate a virtual method indicating that subclasses must not override it, |
| 32 | // or annotate a class to indicate that it cannot be subclassed. |
| 33 | // Use like: |
| 34 | // class B FINAL : public A {}; |
| 35 | // virtual void bar() FINAL; |
| 36 | #if V8_HAS_CXX11_FINAL |
| 37 | #define FINAL final |
| 38 | #elif V8_HAS___FINAL |
| 39 | #define FINAL __final |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 40 | #else |
| 41 | #define FINAL /* NOT SUPPORTED */ |
| 42 | #endif |
| 43 | |
| 44 | |
| 45 | // Annotate a function indicating the caller must examine the return value. |
| 46 | // Use like: |
| 47 | // int foo() WARN_UNUSED_RESULT; |
| 48 | #if V8_HAS_ATTRIBUTE_WARN_UNUSED_RESULT |
| 49 | #define WARN_UNUSED_RESULT __attribute__((warn_unused_result)) |
| 50 | #else |
| 51 | #define WARN_UNUSED_RESULT /* NOT SUPPORTED */ |
| 52 | #endif |
| 53 | |
| 54 | #endif // V8_BASE_COMPILER_SPECIFIC_H_ |