[llvm] r280326 - Support: Avoid errors with LLVM_FALLTHROUGH in clang 3.6 and below in C mode
Justin Bogner via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 31 16:43:14 PDT 2016
Author: bogner
Date: Wed Aug 31 18:43:14 2016
New Revision: 280326
URL: http://llvm.org/viewvc/llvm-project?rev=280326&view=rev
Log:
Support: Avoid errors with LLVM_FALLTHROUGH in clang 3.6 and below in C mode
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.
Modified:
llvm/trunk/include/llvm/Support/Compiler.h
Modified: llvm/trunk/include/llvm/Support/Compiler.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/Compiler.h?rev=280326&r1=280325&r2=280326&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/Compiler.h (original)
+++ llvm/trunk/include/llvm/Support/Compiler.h Wed Aug 31 18:43:14 2016
@@ -235,6 +235,10 @@
/// 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
More information about the llvm-commits
mailing list