Issue 169123
Summary statement in clang extension block impacts indentation
Labels clang
Assignees
Reporter younkhg
    clang-format version 21.1.6

description:
```
int foo(void) {
    a = (AA){
 .f = ^{
            ; // a statement added here
        },
    };
 printf("Hello World!\n"); // impacts this line
}
```

test file used: [sample.c](https://github.com/user-attachments/files/23685486/sample.c)

command and output:
```
> clang-format --version; clang-format sample.c
clang-format version 21.1.6
// this works well
int foo() {
  a = (AA){
      .f =
          ^{
          },
  };
  printf("Hello World!\n");
}

// statement in block impacts following line
int foo2(void) {
  a = (AA){.f = ^{
               ; // a statement added
}
,
}
;
printf("Hello World!\n"); // this line has wrong indent
}

// clang-format off still impacts following line
int foo3(void) {
  // clang-format off
    a = (AA){
        .f = ^{
            ;
 },
    };
// clang-format on
printf("Hello World!\n"); // this line has wrong indent
}

// disabling func as a whole works
// clang-format off
int foo4(void) {
    a = (AA){
        .f = ^{
            ;
 },
    };
    printf("Hello World!\n");
}
// clang-format on
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to