Skip to content

[clang-format] Parenthesized macro argument gets treated as type cast #61603

@ghost

Description

Take for example this line in this file:

#define RTW89_SAR_6GHZ_SPAN_IDX(center_freq) \
        ((((int)(center_freq) - RTW89_SAR_6GHZ_SPAN_HEAD) / 5) / 2)

clang-format removes the spaces around the -.

#define RTW89_SAR_6GHZ_SPAN_IDX(center_freq) \
        ((((int)(center_freq)-RTW89_SAR_6GHZ_SPAN_HEAD) / 5) / 2)

The cause of this problem is 76f98f8. The program would treat
(int)(center_freq) as 2 type casts. The commit comes with this test:

verifyFormat("my_int a = (my_int)(my_int)-1;");

I failed to come up with a good way to fix the problem while having the
aforementioned unit test still pass. So I am submitting a bug report
instead of a patch.

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