Skip to content

[clang-format] bug in c formatting when "switch" appears as a token #114408

Closed
@mtfurlan

Description

@mtfurlan

This is a c file that is correctly formatted according to clang-format 18, but not according to clang-format 19
clang-format --dry-run --Werror --style="{BasedOnStyle: llvm, BreakBeforeBraces: Linux}" test.c

FOOBAR(switch); // if we use a word that isn't "switch" everything is fine
// if we do use "switch", the "BreakBeforeBraces: Linux" isn't respected and it
// tries to do "void foo(void) {"

void foo(void)
{ 
  int i = 5;
  printf("foo: %d\n", i);
}

I bisected it to 236b3e1 [clang-format] Handle Java switch expressions (#91112)

Metadata

Metadata

Assignees

Type

No type

Projects

Status

Done

Relationships

None yet

Development

No branches or pull requests

Issue actions