[llvm-bugs] [Bug 51094] New: -Wimplicit-fallthrough needlessly warning about unreachable code

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Jul 14 13:29:37 PDT 2021


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

            Bug ID: 51094
           Summary: -Wimplicit-fallthrough needlessly warning about
                    unreachable code
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C
          Assignee: unassignedclangbugs at nondot.org
          Reporter: keescook at chromium.org
                CC: blitzrakete at gmail.com, dgregor at apple.com,
                    erik.pilkington at gmail.com, llvm-bugs at lists.llvm.org,
                    richard-llvm at metafoo.co.uk

There are some places in the kernel where the "fallthrough;" annotation is used
after a portion of code that may get elided at build time:

case 1:
    if (something || !IS_ENALBED(CONFIG_SOMETHING))
        return blah;
    fallthrough;
case 2:
This looks like:

case 1:
    fallthrough;
case 2:
And a warning is generated:

warning: fallthrough annotation in unreachable code [-Wimplicit-fallthrough]

But isn't a useful warning in this case, and should likely be silenced or
adjust to not warn where there was actually code there before getting elided.
At the least, this warning would be best moved to a separate flag so it can be
disabled on kernel builds (i.e. GCC does not warn about these cases).

Some specific examples:

https://github.com/ClangBuiltLinux/continuous-integration2/runs/3058126539?check_suite_focus=true#step:5:120
https://github.com/ClangBuiltLinux/continuous-integration2/runs/3058126329?check_suite_focus=true#step:5:92

-- 
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/20210714/ac847f03/attachment.html>


More information about the llvm-bugs mailing list