[PATCH] D33036: [Support/Compiler.h] - Use gnu::fallthrough for LLVM_FALLTHROUGH when available.
George Rimar via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu May 11 02:30:18 PDT 2017
grimar added inline comments.
================
Comment at: Compiler.h:236-237
#define LLVM_FALLTHROUGH [[clang::fallthrough]]
+#elif __has_cpp_attribute(gnu::fallthrough)
+#define LLVM_FALLTHROUGH [[gnu::fallthrough]]
#else
----------------
ruiu wrote:
> I think you want to move this before !__cplusplus to define LLVM_FALLTHROUGH even !__cplusplus.
Looks reasonable, thanks.
Code probably could be something like next for clarity about workaround:
```
#if __cplusplus > 201402L && __has_cpp_attribute(fallthrough)
#define LLVM_FALLTHROUGH [[fallthrough]]
#elif __has_cpp_attribute(gnu::fallthrough)
#define LLVM_FALLTHROUGH [[gnu::fallthrough]]
#elif __cplusplus && __has_cpp_attribute(clang::fallthrough)
// Workaround for llvm.org/PR23435, since clang 3.6 and below emit a spurious
// error when __has_cpp_attribute is given a scoped attribute in C mode.
#define LLVM_FALLTHROUGH [[clang::fallthrough]]
#else
#define LLVM_FALLTHROUGH
#endif
```
https://reviews.llvm.org/D33036
More information about the llvm-commits
mailing list