Index: llvm/trunk/include/llvm/Support/Compiler.h =================================================================== --- llvm/trunk/include/llvm/Support/Compiler.h +++ llvm/trunk/include/llvm/Support/Compiler.h @@ -16,7 +16,9 @@ #include "llvm/Config/llvm-config.h" +#ifdef __cplusplus #include +#endif #include #if defined(_MSC_VER) @@ -252,10 +254,8 @@ #define LLVM_FALLTHROUGH [[fallthrough]] #elif __has_cpp_attribute(gnu::fallthrough) #define LLVM_FALLTHROUGH [[gnu::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 !defined(__cplusplus) && __has_attribute(fallthrough) +#define LLVM_FALLTHROUGH __attribute__((fallthrough)) #elif __has_cpp_attribute(clang::fallthrough) #define LLVM_FALLTHROUGH [[clang::fallthrough]] #else @@ -527,6 +527,7 @@ #define LLVM_ENABLE_EXCEPTIONS 1 #endif +#ifdef __cplusplus namespace llvm { /// Allocate a buffer of memory with the given size and alignment. @@ -569,4 +570,5 @@ } // End namespace llvm +#endif // __cplusplus #endif Index: llvm/trunk/lib/Support/regcomp.c =================================================================== --- llvm/trunk/lib/Support/regcomp.c +++ llvm/trunk/lib/Support/regcomp.c @@ -48,6 +48,7 @@ #include "regex2.h" #include "llvm/Config/config.h" +#include "llvm/Support/Compiler.h" /* character-class table */ static struct cclass { @@ -537,7 +538,7 @@ break; case '{': /* okay as ordinary except if digit follows */ REQUIRE(!MORE() || !isdigit((uch)PEEK()), REG_BADRPT); - /* fall through */ + LLVM_FALLTHROUGH; default: ordinary(p, c); break; @@ -733,7 +734,7 @@ break; case '*': REQUIRE(starordinary, REG_BADRPT); - /* fall through */ + LLVM_FALLTHROUGH; default: ordinary(p, (char)c); break; @@ -1635,7 +1636,7 @@ return; } } while (OP(s) != O_QUEST && OP(s) != O_CH); - /* fall through */ + LLVM_FALLTHROUGH; default: /* things that break a sequence */ if (newlen > g->mlen) { /* ends one */ start = newstart;