[LLVMbugs] [Bug 18619] New: Clang should allow unreachable [[clang::fallthrough]] in template functions if any template expansion uses it

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Sat Jan 25 20:17:17 PST 2014


http://llvm.org/bugs/show_bug.cgi?id=18619

            Bug ID: 18619
           Summary: Clang should allow unreachable [[clang::fallthrough]]
                    in template functions if any template expansion uses
                    it
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: joepeck02 at gmail.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Created attachment 11940
  --> http://llvm.org/bugs/attachment.cgi?id=11940&action=edit
[TEST] Example file

See attached test case.

    template<bool strict>
    void doSomething(char c)
    {
        switch (c) {
            case 'a': {
                if (strict) return;
                [[clang::fallthrough]];
            }
            default:
                break;
        }
    }

Compiling the above will either warn about doSomething<true> with an
unreachable fall through, or doSomething<false> missing [[clang::fallthrough]]:

    example.cpp:11:13: warning: fallthrough annotation in unreachable code
[-Wimplicit-fallthrough]
                [[clang::fallthrough]];
                ^
    example.cpp:20:5: note: in instantiation of function template
specialization 'doSomething<true>' requested here
        doSomething<true>('a');
        ^
    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/20140126/e679a084/attachment.html>


More information about the llvm-bugs mailing list