[llvm-bugs] [Bug 30636] New: an impossible case for -Wimplicit-fallthrough and [[clang::fallthrough]]

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Oct 7 09:14:28 PDT 2016


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

            Bug ID: 30636
           Summary: an impossible case for -Wimplicit-fallthrough and
                    [[clang::fallthrough]]
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: aduret at gmail.com
                CC: dgregor at apple.com, llvm-bugs at lists.llvm.org
    Classification: Unclassified

Here is a function that I have reduced from some real-life code that I am
unable to compile with -Wimplicit-fallthrough.


% cat foo.cc
template<bool param>
int fun(int i)
{
  switch (i)
    {
    case 1:
      if (param)
        return 3;
      // [[clang::fallthrough]];
    case 2:
      return 4;
    default:
      return 5;
    }
}

template int fun<true>(int);
template int fun<false>(int);

% clang++-3.9 -std=c++11 -Wimplicit-fallthrough foo.cc -cfoo.cc:10:5: warning:
unannotated fall-through between switch labels [-Wimplicit-fallthrough]
    case 2:
    ^
foo.cc:18:14: note: in instantiation of function template specialization
'fun<false>' requested here
template int fun<false>(int);
             ^
foo.cc:10:5: note: insert '[[clang::fallthrough]];' to silence this warning
[...]


Unfortunately, inserting [[clang::fallthrough]] gives a different error:

% clang++-3.9 -std=c++11 -Wimplicit-fallthrough foo.cc -c
foo.cc:9:7: warning: fallthrough annotation in unreachable code
[-Wimplicit-fallthrough]
      [[clang::fallthrough]];
      ^
foo.cc:17:14: note: in instantiation of function template specialization
'fun<true>' requested here
template int fun<true>(int);
             ^
1 warning generated.

-- 
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/20161007/2ffb7b44/attachment.html>


More information about the llvm-bugs mailing list