[PATCH] D66487: Fix -Wimplicit-fallthrough warnings in regcomp.c

Aaron Ballman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 20 12:45:46 PDT 2019


aaron.ballman added inline comments.


================
Comment at: llvm/lib/Support/regcomp.c:540
 		REQUIRE(!MORE() || !isdigit((uch)PEEK()), REG_BADRPT);
-		/* FALLTHROUGH */
+		__attribute__((fallthrough));
 	default:
----------------
Nathan-Huckleberry wrote:
> aaron.ballman wrote:
> > nickdesaulniers wrote:
> > > aaron.ballman wrote:
> > > > The macros in Compiler.h should be updated so that this can use `LLVM_FALLTHROUGH` instead to prevent compile errors.
> > > ah, right, otherwise we get into situations where older versions of clang (or other bootstrap compilers) that don't have this feature don't understand this attribute
> > Yes, as-is this would break everyone building Clang with MSVC (for instance).
> I'm having problems including `Compiler.h` from a c file. I can't include a cpp header into a c file.
> 
> ```
> In file included from llvm/llvm-project/llvm/lib/Support/regcomp.c:51:
> llvm/llvm-project/llvm/include/llvm/Support/Compiler.h:19:10: fatal error: 'new' file not found
> #include <new>
>          ^~~~~
> ```
You will have to add the appropriate conditionals to Compiler.h as part of the work. It seems it's already been done in some places, so it hopefully will not be too onerous. Adding an include to Compiler.h from a C file will help ensure we don't regress this functionality again in the future, which is a nice bonus.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D66487/new/

https://reviews.llvm.org/D66487





More information about the llvm-commits mailing list