From a828bf5f58982c01c69b8ccf0f2c81eb109071c1 Mon Sep 17 00:00:00 2001 From: Rahul Frias Date: Fri, 12 Mar 2021 00:57:07 -0800 Subject: [PATCH] Annotate fallthrough in OEC Testbed [ Merge of http://go/wvgerrit/119230 ] This patch adds an annotation to the one place in the codebase where we intentionally fall through between switch statement cases, in order to appease stricter compilers. Bug: 182058081 Test: compile, WV unit/integration tests Change-Id: I004a6a6e61681fcf22c6bf25d9b0284b8b64e776 --- libwvdrmengine/cdm/util/include/util_common.h | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/libwvdrmengine/cdm/util/include/util_common.h b/libwvdrmengine/cdm/util/include/util_common.h index 5e7b1661..7b28c482 100644 --- a/libwvdrmengine/cdm/util/include/util_common.h +++ b/libwvdrmengine/cdm/util/include/util_common.h @@ -5,20 +5,27 @@ #ifndef WVCDM_UTIL_UTIL_COMMON_H_ #define WVCDM_UTIL_UTIL_COMMON_H_ +// This section deals with defines that are platform-specific. + #ifdef _WIN32 + # ifdef CORE_UTIL_IMPLEMENTATION # define CORE_UTIL_EXPORT __declspec(dllexport) # else # define CORE_UTIL_EXPORT __declspec(dllimport) # endif + # define CORE_UTIL_IGNORE_DEPRECATED # define CORE_UTIL_RESTORE_WARNINGS + #else + # ifdef CORE_UTIL_IMPLEMENTATION # define CORE_UTIL_EXPORT __attribute__((visibility("default"))) # else # define CORE_UTIL_EXPORT # endif + # ifdef __GNUC__ # define CORE_UTIL_IGNORE_DEPRECATED \ _Pragma("GCC diagnostic push") \ @@ -28,6 +35,23 @@ # define CORE_UTIL_IGNORE_DEPRECATED # define CORE_UTIL_RESTORE_WARNINGS # endif + +#endif + +// This section deals with attribute-detection and is platform-agnostic. + +#if !defined(__has_cpp_attribute) +# define __has_cpp_attribute(x) 0 +#endif + +#if __has_cpp_attribute(fallthrough) +# define CORE_UTIL_FALLTHROUGH [[fallthrough]] +#elif __has_cpp_attribute(clang::fallthrough) +# define CORE_UTIL_FALLTHROUGH [[clang::fallthrough]] +#elif __has_cpp_attribute(gnu::fallthrough) +# define CORE_UTIL_FALLTHROUGH [[gnu::fallthrough]] +#else +# define CORE_UTIL_FALLTHROUGH #endif #endif // WVCDM_UTIL_UTIL_COMMON_H_