Support: Avoid errors with LLVM_FALLTHROUGH in clang 3.6 and below in C mode
authorJustin Bogner <mail@justinbogner.com>
Wed, 31 Aug 2016 23:43:14 +0000 (23:43 +0000)
committerJustin Bogner <mail@justinbogner.com>
Wed, 31 Aug 2016 23:43:14 +0000 (23:43 +0000)
Older versions of clang defined __has_cpp_attribute in C mode, but
would choke on scoped attributes, as per llvm.org/PR23435. Since we
support building with clang all the way back to 3.1, we have to work
around this issue.

llvm-svn: 280326

llvm/include/llvm/Support/Compiler.h

index a9b2e43..3cf9910 100644 (file)
 /// LLVM_FALLTHROUGH - Mark fallthrough cases in switch statements.
 #if __cplusplus > 201402L && __has_cpp_attribute(fallthrough)
 #define LLVM_FALLTHROUGH [[fallthrough]]
+#elif !__cplusplus
+// 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
 #elif __has_cpp_attribute(clang::fallthrough)
 #define LLVM_FALLTHROUGH [[clang::fallthrough]]
 #else