blob: 9755fc13ce6c077dcd179dcd0ebb74d1eba59906 [file] [log] [blame]
Ben Murdochb8a8cc12014-11-26 15:28:44 +00001// 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 Bernierd0a1eb72015-03-24 16:35:39 -040010// Annotate a typedef or function indicating it's ok if it's not used.
Ben Murdochb8a8cc12014-11-26 15:28:44 +000011// Use like:
Emily Bernierd0a1eb72015-03-24 16:35:39 -040012// typedef Foo Bar ALLOW_UNUSED_TYPE;
Ben Murdochb8a8cc12014-11-26 15:28:44 +000013#if V8_HAS_ATTRIBUTE_UNUSED
Emily Bernierd0a1eb72015-03-24 16:35:39 -040014#define ALLOW_UNUSED_TYPE __attribute__((unused))
Ben Murdochb8a8cc12014-11-26 15:28:44 +000015#else
Emily Bernierd0a1eb72015-03-24 16:35:39 -040016#define ALLOW_UNUSED_TYPE
Ben Murdochb8a8cc12014-11-26 15:28:44 +000017#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 Murdochb8a8cc12014-11-26 15:28:44 +000040#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_