[PATCH] D63260: [Attr] Support _attribute__ ((fallthrough))

Nick Desaulniers via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 13 11:17:58 PDT 2019


nickdesaulniers added inline comments.


================
Comment at: lib/Sema/AnalysisBasedWarnings.cpp:1279
         continue;
-      if (S.getLangOpts().CPlusPlus11) {
+      if (S.getLangOpts().CPlusPlus11 || S.getLangOpts().C99) {
         const Stmt *Term = B->getTerminatorStmt();
----------------
xbolva00 wrote:
> nickdesaulniers wrote:
> > Probably should additionally/instead check `S.getLangOpts().GNUMode` (since these are GNU C style attributes)?  I guess we want these attributes to be supported in C regardless of `-std=`?
> Good point.
IIUC, we allow GNU C attributes for C regardless of ISO vs GNU C.  What we want to express is "if c++11 and newer, or c".

I think this might be better expressed as:

```
if (S.getLangOpts().CPlusPlus11 || (!S.getLangOpts().CPlusPlus && !S.getLangOpts().ObjC) {
```

But maybe there's a more canonical way to express "if the language is C." (If not, maybe we can consider such a change to `LangOpt` to make this easier, but as part of this commit).


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

https://reviews.llvm.org/D63260





More information about the cfe-commits mailing list