Issue 61585
Summary formating breaks in array without trailing comma
Labels new issue
Assignees
Reporter fneddy
    

i have a very strange behavior with my current .clang-format file.

here is the file:
```
---
BasedOnStyle: LLVM
ColumnLimit: 200
IndentWidth: 4
UseTab: Always
TabWidth: 4
BreakBeforeBraces: Linux
```

considering this example C code it will format it as expected:
```
struct foo {
    char a;
    int b;
};

static const struct foo data[] = {
    {'a', 1},
    {'b', 2},
    {'c', 3},
};
```

however if i remove the trailing `,` the formatting will not break the lines any more

```
struct foo {
    char a;
    int b;
};

static const struct foo data[] = {{'a', 1}, {'b', 2}, {'c', 3}};
```

it seems that this is a bug due to a missing `,` after the last array element.  however this is `C` and not json so there shouldn't be a trailing `,` . e.g. C std pdf N2310 ยง 6.7.9 make all examples of initializer lists without trailing commas 

_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to