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

            Bug ID: 49454
           Summary: C++20 `[[likely]]`/`[[unlikely]]` `case` statements
                    erroneously fail to compile in the presence of
                    `[[fallthrough]]`
           Product: new-bugs
           Version: unspecified
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected]

See the following complete example:

    //Compile with "-std=c++20"
    void f(int i) {
        switch (i) {
                [[likely]] case 1:
                        [[fallthrough]];
                case 2:
                        break;
        }
    }

This should compile (and does on every other compiler), but doesn't on Clang. 
Clang (tested 13.0.0) produces:

    <source>:5:13: error: fallthrough annotation does not directly precede
switch label
                [[fallthrough]];
                ^

Removing either `[[likely]]` or `[[fallthrough]];` is sufficient to cause the
compile to succeed.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to