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: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected]
    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.
_______________________________________________
llvm-bugs mailing list
[email protected]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to