Karl Wiberg | 80ba333 | 2018-02-05 10:33:35 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2018 The WebRTC project authors. All Rights Reserved. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license |
| 5 | * that can be found in the LICENSE file in the root of the source |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 | |
| 11 | #ifndef RTC_BASE_SYSTEM_FALLTHROUGH_H_ |
| 12 | #define RTC_BASE_SYSTEM_FALLTHROUGH_H_ |
| 13 | |
| 14 | // Macro to be used for switch-case fallthrough (required for enabling |
| 15 | // -Wimplicit-fallthrough warning on Clang). |
| 16 | |
| 17 | // This macro definition must not be included from public headers! Because |
| 18 | // clang's diagnostic checks if there's a macro expanding to |
| 19 | // [[clang::fallthrough]] defined, and if so it suggests the first macro |
| 20 | // expanding to it. So if this macro is included in a public header, clang may |
| 21 | // suggest it instead of the client's own macro, which can cause confusion. |
| 22 | |
| 23 | #ifdef __clang__ |
| 24 | #define RTC_FALLTHROUGH() [[clang::fallthrough]] |
| 25 | #else |
| 26 | #define RTC_FALLTHROUGH() \ |
| 27 | do { \ |
| 28 | } while (0) |
| 29 | #endif |
| 30 | |
| 31 | #endif // RTC_BASE_SYSTEM_FALLTHROUGH_H_ |