Skip to content

statement in clang extension block impacts indentation #169123

@younkhg

Description

@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

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions