[llvm-bugs] [Bug 46167] New: clang-format is confused by C99 array initializers.

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Jun 1 14:11:55 PDT 2020


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

            Bug ID: 46167
           Summary: clang-format is confused by C99 array initializers.
           Product: clang
           Version: 10.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Formatter
          Assignee: unassignedclangbugs at nondot.org
          Reporter: phil at kantaka.co.uk
                CC: djasper at google.com, klimek at google.com,
                    llvm-bugs at lists.llvm.org

Take:

struct S2 {
  int x, y;
};

struct S2 a1[3] = {1, 2, 3, 4, 5, 6};

struct S2 a2[3] =
{
  {1, 2},
  {3, 4},
  5, 6
};

struct S2 a4[3] =
{
  // Current object is all of a4
  [0].x=1, [0].y=2,
  {
     // Current object is a4[1]
     x=3, .y=4
  }
  // Current object is all of a4
  // Current position is [2]
  5, [2].y=6
};

clang-format will output something reasonable for a1 & a2, so long as they fit
on one line, but for a4 it will output:

struct S2 a4[3] = {
    // Current object is all of a4
    [0].x = 1,
    [0].y = 2,
    {// Current object is a4[1]
     x = 3, .y = 4}
    // Current object is all of a4
    // Current position is [2]
    5,
    [2].y = 6};

The .name = value format is possibly confusing it?

-- 
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/20200601/d8288cac/attachment.html>


More information about the llvm-bugs mailing list