https://bugs.llvm.org/show_bug.cgi?id=47571

            Bug ID: 47571
           Summary: clang-format: cannot correctly format the C source
                    code with CPP keywords.
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Formatter
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected],
                    [email protected]

This is my configuration file:

```
---
AccessModifierOffset: -4
AlignAfterOpenBracket: Align
AllowShortIfStatementsOnASingleLine: false
BasedOnStyle: LLVM
BreakBeforeBraces: WebKit
ColumnLimit: 0
IndentWidth: 4
IndentCaseLabels: false
Language: Cpp
TabWidth: 4
UseTab: Never
```

This is part of my code, it has been formatted:

```c
/* linkedlist.h */
#ifndef LINKEDLIST_H
#define LINKEDLIST_H

typedef struct node *link;
struct node {
    unsigned char item;
    link next;
};

link make_node(unsigned char item);
void free_node(link p);
link search(unsigned char key);
void insert(link p);
void delete (link p);
void traverse(void (*visit)(link));
void destroy(void);
void push(link p);
link pop(void);

#endif
```

In theory, my `delete` function declaration should be formatted as: `void
delete(link p)`;
However, the formatter added a space between `delete` and `(`. This seems to
treat my `delete` signature as a keyword.
This is wrong for C code.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to