OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef BASE_COMPILER_SPECIFIC_H_ | 5 #ifndef BASE_COMPILER_SPECIFIC_H_ |
6 #define BASE_COMPILER_SPECIFIC_H_ | 6 #define BASE_COMPILER_SPECIFIC_H_ |
7 | 7 |
8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
9 | 9 |
10 #if defined(COMPILER_MSVC) | 10 #if defined(COMPILER_MSVC) |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 #endif | 134 #endif |
135 | 135 |
136 // Annotate a virtual method indicating it must be overriding a virtual | 136 // Annotate a virtual method indicating it must be overriding a virtual |
137 // method in the parent class. | 137 // method in the parent class. |
138 // Use like: | 138 // Use like: |
139 // virtual void foo() OVERRIDE; | 139 // virtual void foo() OVERRIDE; |
140 #if defined(COMPILER_MSVC) | 140 #if defined(COMPILER_MSVC) |
141 #define OVERRIDE override | 141 #define OVERRIDE override |
142 #elif defined(__clang__) | 142 #elif defined(__clang__) |
143 #define OVERRIDE override | 143 #define OVERRIDE override |
| 144 #elif defined(COMPILER_GCC) && __cplusplus >= 201103 && \ |
| 145 (__GNUC__ * 10000 + __GNUC_MINOR__ * 100) >= 40700 |
| 146 // GCC 4.7 supports explicit virtual overrides when C++11 support is enabled. |
| 147 #define OVERRIDE override |
144 #else | 148 #else |
145 #define OVERRIDE | 149 #define OVERRIDE |
146 #endif | 150 #endif |
147 | 151 |
148 // Annotate a virtual method indicating that subclasses must not override it, | 152 // Annotate a virtual method indicating that subclasses must not override it, |
149 // or annotate a class to indicate that it cannot be subclassed. | 153 // or annotate a class to indicate that it cannot be subclassed. |
150 // Use like: | 154 // Use like: |
151 // virtual void foo() FINAL; | 155 // virtual void foo() FINAL; |
152 // class B FINAL : public A {}; | 156 // class B FINAL : public A {}; |
153 #if defined(COMPILER_MSVC) | 157 #if defined(COMPILER_MSVC) |
154 // TODO(jered): Change this to "final" when chromium no longer uses MSVC 2010. | 158 // TODO(jered): Change this to "final" when chromium no longer uses MSVC 2010. |
155 #define FINAL sealed | 159 #define FINAL sealed |
156 #elif defined(__clang__) | 160 #elif defined(__clang__) |
157 #define FINAL final | 161 #define FINAL final |
| 162 #elif defined(COMPILER_GCC) && __cplusplus >= 201103 && \ |
| 163 (__GNUC__ * 10000 + __GNUC_MINOR__ * 100) >= 40700 |
| 164 // GCC 4.7 supports explicit virtual overrides when C++11 support is enabled. |
| 165 #define FINAL final |
158 #else | 166 #else |
159 #define FINAL | 167 #define FINAL |
160 #endif | 168 #endif |
161 | 169 |
162 // Annotate a function indicating the caller must examine the return value. | 170 // Annotate a function indicating the caller must examine the return value. |
163 // Use like: | 171 // Use like: |
164 // int foo() WARN_UNUSED_RESULT; | 172 // int foo() WARN_UNUSED_RESULT; |
165 // To explicitly ignore a result, see |ignore_result()| in <base/basictypes.h>. | 173 // To explicitly ignore a result, see |ignore_result()| in <base/basictypes.h>. |
166 #if defined(COMPILER_GCC) | 174 #if defined(COMPILER_GCC) |
167 #define WARN_UNUSED_RESULT __attribute__((warn_unused_result)) | 175 #define WARN_UNUSED_RESULT __attribute__((warn_unused_result)) |
(...skipping 29 matching lines...) Expand all Loading... |
197 | 205 |
198 // Mark a memory region fully initialized. | 206 // Mark a memory region fully initialized. |
199 // Use this to annotate code that deliberately reads uninitialized data, for | 207 // Use this to annotate code that deliberately reads uninitialized data, for |
200 // example a GC scavenging root set pointers from the stack. | 208 // example a GC scavenging root set pointers from the stack. |
201 #define MSAN_UNPOISON(p, s) __msan_unpoison(p, s) | 209 #define MSAN_UNPOISON(p, s) __msan_unpoison(p, s) |
202 #else // MEMORY_SANITIZER | 210 #else // MEMORY_SANITIZER |
203 #define MSAN_UNPOISON(p, s) | 211 #define MSAN_UNPOISON(p, s) |
204 #endif // MEMORY_SANITIZER | 212 #endif // MEMORY_SANITIZER |
205 | 213 |
206 #endif // BASE_COMPILER_SPECIFIC_H_ | 214 #endif // BASE_COMPILER_SPECIFIC_H_ |
OLD | NEW |