Skip to content
Snippets Groups Projects
Commit aad80e47 authored by Bas Nieuwenhuizen's avatar Bas Nieuwenhuizen Committed by Marge Bot
Browse files

util: Add support for clang::fallthrough.


Looks like the __attribute__ version doesn't work for C++ in the
Android build. Only found now because we don't enable
-Wimplicit-fallthrough by default project wide for C++. Only
ACO enables it.

Reviewed-by: default avatarSamuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <!13164>
parent 966c171d
No related branches found
No related tags found
No related merge requests found
......@@ -76,9 +76,20 @@
# define __has_attribute(x) 0
#endif
#if defined(__has_cpp_attribute) && defined(__clang__)
/* We do not do the same trick as __has_attribute because parsing
* clang::fallthrough in the preprocessor fails in GCC. */
# define HAS_CLANG_FALLTHROUGH __has_cpp_attribute(clang::fallthrough)
#else
# define HAS_CLANG_FALLTHROUGH 0
#endif
#if __cplusplus >= 201703L || __STDC_VERSION__ > 201710L
/* Standard C++17/C23 attribute */
#define FALLTHROUGH [[fallthrough]]
#elif HAS_CLANG_FALLTHROUGH
/* Clang++ specific */
#define FALLTHROUGH [[clang::fallthrough]]
#elif __has_attribute(fallthrough)
/* Non-standard but supported by at least gcc and clang */
#define FALLTHROUGH __attribute__((fallthrough))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment