Skip to content

Commit a44a873

Browse files
committed
sanitizer_common: add FALLTHROUGH macro
Add FALLTHROUGH portably defined to [[clang::fallthrough]]. We have -Wimplicit-fallthrough already enabled, and currently it's not possible to fix the warning. Depends on D107735. Reviewed By: melver Differential Revision: https://reviews.llvm.org/D107736
1 parent 3cb4ed7 commit a44a873

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,10 @@
125125
# define __has_attribute(x) 0
126126
#endif
127127

128+
#if !defined(__has_cpp_attribute)
129+
# define __has_cpp_attribute(x) 0
130+
#endif
131+
128132
// For portability reasons we do not include stddef.h, stdint.h or any other
129133
// system header, but we do need some basic types that are not defined
130134
// in a portable way by the language itself.
@@ -250,6 +254,12 @@ typedef u64 tid_t;
250254
# define NOEXCEPT throw()
251255
#endif
252256

257+
#if __has_cpp_attribute(clang::fallthrough)
258+
# define FALLTHROUGH [[clang::fallthrough]]
259+
#else
260+
# define FALLTHROUGH
261+
#endif
262+
253263
// Unaligned versions of basic types.
254264
typedef ALIGNED(1) u16 uu16;
255265
typedef ALIGNED(1) u32 uu32;

0 commit comments

Comments
 (0)