[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
Wed May 10 06:15:24 PDT 2017


grimar created this revision.

I tried to compile LLD using GCC 7.1.0 and got warnings like 
"warning: this statement may fall through [-Wimplicit-fallthrough=]"
(some more details are here: https://reviews.llvm.org/D32907)

GCC's __cplusplus value is 201402L by default, so macro expands to nothing,
though GCC 7 has support for [[fallthrough]].

I suggest to use gnu::fallthrough when it is available. That fixes issue I am observing.


https://reviews.llvm.org/D33036

Files:
  Compiler.h


Index: Compiler.h
===================================================================
--- Compiler.h
+++ Compiler.h
@@ -233,6 +233,8 @@
 #define LLVM_FALLTHROUGH
 #elif __has_cpp_attribute(clang::fallthrough)
 #define LLVM_FALLTHROUGH [[clang::fallthrough]]
+#elif __has_cpp_attribute(gnu::fallthrough)
+#define LLVM_FALLTHROUGH [[gnu::fallthrough]]
 #else
 #define LLVM_FALLTHROUGH
 #endif


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D33036.98435.patch
Type: text/x-patch
Size: 391 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170510/d6841d56/attachment.bin>


More information about the llvm-commits mailing list