[llvm-bugs] [Bug 37135] New: Fallthrough attr should support GNU spelling __attribute__((fallthrough)) to match GCC 7

via llvm-bugs llvm-bugs at lists.llvm.org
Sat Apr 14 16:25:55 PDT 2018


https://bugs.llvm.org/show_bug.cgi?id=37135

            Bug ID: 37135
           Summary: Fallthrough attr should support GNU spelling
                    __attribute__((fallthrough)) to match GCC 7
           Product: clang
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Frontend
          Assignee: unassignedclangbugs at nondot.org
          Reporter: comexk at gmail.com
                CC: llvm-bugs at lists.llvm.org

From
https://developers.redhat.com/blog/2017/03/10/wimplicit-fallthrough-in-gcc-7/,
GCC supports this syntax:

switch (cond)
 {
 case 1:
   bar (1);
   __attribute__ ((fallthrough)); // C and C++03
 case 2:
   bar (2);
   [[gnu::fallthrough]]; // C++11 and C++14
 case 3:
   bar (3);
   [[fallthrough]]; // C++17 and above
 /* ... */
 }

Clang's current definition in Attr.td:

def FallThrough : StmtAttr {
  let Spellings = [CXX11<"", "fallthrough", 201603>, C2x<"", "fallthrough">,
                   CXX11<"clang", "fallthrough">];
  [..]
}

I think GCC<"fallthrough"> needs to be added.

This check in lib/Sema/AnalysisBasedWarnings.cpp should then be removed:

  // Only perform this analysis when using [[]] attributes. There is no good
  // workflow for this warning when not using C++11. There is no good way to
  // silence the warning (no attribute is available) unless we are using 
  // [[]] attributes. One could use pragmas to silence the warning, but as a
  // general solution that is gross and not in the spirit of this warning.
  //
  // NOTE: This an intermediate solution. There are on-going discussions on
  // how to properly support this warning outside of C++11 with an annotation.
  if (!AC.getASTContext().getLangOpts().DoubleSquareBracketAttributes)
    return;

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20180414/db5ac690/attachment.html>


More information about the llvm-bugs mailing list