<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/145651>145651</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [clang-tidy] `bugprone-signed-char-misuse` gives false positives in C23 for enum with signed char type
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang-tidy
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          bjosv
      </td>
    </tr>
</table>

<pre>
    When running `bugprone-signed-char-misuse` on C23 code that uses [enums](https://en.cppreference.com/w/c/language/enum.html
) with a fixed underlying type of `signed char` we get warnings.
```
enum e : signed char {
    E_M128 = -128,
};

enum e state = E_M128;
```
A full example:
https://godbolt.org/z/vGTj966TY

The checker gets that the RHS EnumConstant is a `signed char` but don't use the fact that LHS is of type signed char, giving a warning.

The RHS seems to give the AST
`ImplicitCastExpr <col:13> 'e_t':'enum e' <IntegralCast>`
but we have not found anything in the standard that motivates the warning and we believe it's a false positive.


</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJyMk8GPqzYQxv-a4TJK5JgQ4MCBTULfk9pLd6WqpyeDB_DW2AgbsulfXxlSbbrq4UlIHDzfzDc_-xPOqc4QFZC8QHKJxOx7OxX1u3VLVFt5L_7oyeA0G6NMh3Bi9dyNkzW0W4Vy1_Ri2g3KzY7gxNAaPPMYGysJfS88zo4cQvJCZh4cJBfgWe_96CAugVfAKzL7Zhwnamki09C-sQPw6ga8aoBXWphuFh2thfOw7_2ggZXAc7wp36PAVn2QxNlImvQ9mPT3kdC2wezmEYPHYO5G2JHHm5jCNm4fGp3Y42NlGICEEJf4JERIX4CViIjXH78deIYQX3B34Bnwc-iQXiAOFZ8dnBee1rJN8Th_GlViO2uN9CGGUVNgwcr_YumsrK32ezt1wKu_gVfLL2_v-en09uc2660nbHpq_qIpbOU23L4n_P3bK17NPJytcV4Yj8qh-B8c9exRWgM8Xa9p1bai8VunX7-9BqFtN6DPWn7GTi2BtfgX5v7TVBjviAaH3oa6rXH5-rYx-D6MWjXKn4Xz149xQojPjdUQl4cY4isCT-mHB56uKNINKfA01H03nrpJ6KCF-LqxDGvcCHuxEBrrsbWzkSjM3ffBojLr_EBCikluyw3Wq0V4cuvZYwcURoZONWlFC6EKLgK6VmhHOFqnvFrosWoki1jmcS4iKg5pwrIjS5M46osmy1idkTwe67iWjeSS5dmxPvImzxNiSaQKznjCTjxhWZwf4j3Ls0Rwnh6kYA2JGo6MBqH0XutlCC8gUs7NVByOySk5RFrUpN0aWc6bkJCdV_IOnIcIT0VQ7eq5c3BkWjnvPvt45fUa9idZcvmJXId7dF9AuMA2pL21E673tEbyOTvh6UTzpIsvj1v5fq4fUQ_mHr_dONl3ajzwat3YAa8eSy8F_ycAAP__rHt-tA">