[llvm-bugs] [Bug 44487] New: Commenting out case lines in switch statement. Last case behaves differently.

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Jan 8 05:03:37 PST 2020


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

            Bug ID: 44487
           Summary: Commenting out case lines in switch statement. Last
                    case behaves differently.
           Product: clang
           Version: 8.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Formatter
          Assignee: unassignedclangbugs at nondot.org
          Reporter: jzpigtc4zsi at 0box.eu
                CC: djasper at google.com, klimek at google.com,
                    llvm-bugs at lists.llvm.org

In the midst of a switch statement, clang-format recognizes if a case line is
commented out. But at the end, at the last case, does *not*. At least in
version 8. At least I did not succeed to make such configuration file
(.clang-format) which eliminates this inconsistent behaviour.


$ clang-format -version
clang-format version 8.0.0-3 (tags/RELEASE_800/final)

$ cat gg.c
switch (a) {
case A: blah(1); break;
case B: blah(2); break;
// case C: blah(3); break;
case D: blah(4); break;
}

$ cat g1.c
switch (a) {
case A: blah(1); break;
case B: blah(2); break;
case C: blah(3); break;
// case D: blah(4); break;
}

$ clang-format -style=file gg.c 
switch (a) {
case A: blah(1); break;
case B: blah(2); break;
// case C: blah(3); break;
case D: blah(4); break;
}

$ clang-format -style=file g1.c
switch (a) {
case A: blah(1); break;
case B: blah(2); break;
case C:
   blah(3);
   break;
   // case D: blah(4); break;
}

-- 
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/20200108/7df2bd98/attachment.html>


More information about the llvm-bugs mailing list