mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-22 08:47:28 +01:00
Tweak the WUFFS_BASE__FALLTHROUGH macro
When compiling with "-Werror,-Wimplicit-fallthrough", commitc90cc7b6tweaked WUFFS_BASE__FALLTHROUGH to work with newer clang compilers, when defined(__cplusplus) is false, but inadvertently broke older clang compilers, when __has_attribute(fallthrough) is false. This commit reverts some ofc90cc7b6to handle more cases. The next two commits will delete the WUFFS_BASE__FALLTHROUGH macro entirely and render this commit redundant, as the whole business is proving more trouble than it's worth. But it's checked into the commit history in case somebody in the future wants to revive WUFFS_BASE__FALLTHROUGH.
This commit is contained in:
1 parent
963a574f7d
commit
fd90553a8f
3 files changed
+25
-11
No files matched your search
@@ -10111,17 +10111,24 @@ extern "C" {
|
||||
|
||||
// Denote intentional fallthroughs for -Wimplicit-fallthrough.
|
||||
//
|
||||
// The two #if lines are deliberately separate. Combining the two conditions
|
||||
// into a single "#if foo && bar" line would not be portable. See
|
||||
// The next two #if lines are deliberately separate. Combining the two
|
||||
// conditions into a single "#if foo && bar" line would not be portable. See
|
||||
// https://gcc.gnu.org/onlinedocs/cpp/_005f_005fhas_005fattribute.html
|
||||
#if defined(__has_attribute)
|
||||
#if __has_attribute(fallthrough)
|
||||
#define WUFFS_BASE__FALLTHROUGH __attribute__((fallthrough))
|
||||
#endif
|
||||
#endif
|
||||
// Newer C/C++ compilers are handled above. Other compilers are handled below.
|
||||
#if !defined(WUFFS_BASE__FALLTHROUGH)
|
||||
// Chromium's clang-based PNaCl compiler does define __has_attribute, but
|
||||
// "__has_attribute(fallthrough)" is false and "__attribute__((fallthrough))"
|
||||
// has no effect. Use the C++ style "[[clang::fallthrough]]" instead.
|
||||
#if defined(__clang__) && defined(__cplusplus) && (__cplusplus >= 201103L)
|
||||
#define WUFFS_BASE__FALLTHROUGH [[clang::fallthrough]]
|
||||
#else
|
||||
#define WUFFS_BASE__FALLTHROUGH
|
||||
#endif
|
||||
#else
|
||||
#define WUFFS_BASE__FALLTHROUGH
|
||||
#endif
|
||||
|
||||
// Use switch cases for coroutine suspension points, similar to the technique
|
||||
|
||||
Reference in new issue
Block a user