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: unassignedclangb...@nondot.org
          Reporter: p...@kantaka.co.uk
                CC: djas...@google.com, kli...@google.com,
                    llvm-bugs@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.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to