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

    <tr>
        <th>Summary</th>
        <td>
            libclang 18.1.6 doesn't identify an implicit cast to int from a boolean expression when used inside of an init list
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

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

    <tr>
      <th>Reporter</th>
      <td>
          f-cozzocrea
      </td>
    </tr>
</table>

<pre>
    When analysing C code, libclang isn't identifying an implicit cast from a boolean expression to an int field of a struct when the expression is inside of an init list. Here's a minimal example:

```C
typedef struct {
  int a;
} bar_t;

bar_t test_bool(int b) {
  return (bar_t){.a = b != 0};
}
```
In this example, calling `getStmtClass()` on the expression  `.a = b != 0` returns the value `BinaryOperator`, when it should return `ImplicitCastExpr`.

libclang's `getStmtClass()` correctly returns `ImplicitCastExpr` when the expression is a field access instead of an init list. eg.
```C
bar_t test_bool(int b) {
  bar_t x;
  x.a = b !=0; // <-- ImplicitCastExpr correctly identified here
  return x;
}
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyMVEGv4jYQ_jXOZURkbEjIIYcCRd1TDz30uJokE3Dl2JE9eQv76ysnPJa-t1QrIRM7n2fmm_nyYYzm7Ihqsd2L7THDiS8-1P2q9d-_-zYQZo3vbvXfF3KADu0tGneGA7S-I6EOYE3TWnRnMNEJVTKYjhyb_pZg6MAMozWtYWgxMvTBD4DQeG8JHdB1DBSj8Q7Yz2jH0BuyHfgeECKHqWX4lpLzhZ7xJoJx0XQ0I9NNw2BN5Bz-oEBClREQBuPMgBboisNoSejfhDwK-b4Wcvkdlj3fRuqof08ryv1yDnNdKPR9L8ojNBi-8o-TeZ3PgCny18RQqF261whVPccKxFNwINRuiaEqUe5zBKGP0IBQ6_QgRXl8zveh4GX7JXXFxAc7dYAWrU2dF4U8E__FAx8sxijULuUpJPhPnUzYz-kLeS80zvg3tBMl5N44DLc_RwrIPqRS1GEZkGGIFz_Z7sGwkF_u0z9g5N-vY8Lnzx17V888rpc1tz4EatneHiX9PPQroeBdU9i2FGfdMGH3WTh0zn8ujF8b7IK6PsYGcP3QVyn0HoQ6CXUCoQ-rFXxk8cT1_iEZ6uCSFP1f-Vz_Rx1ZV-uu0hVmVK_LdVFU2-1OZZda7ZrtWiP1RaH6dd8Xm6bYNGWH3YbKDVaZqZVUG7lVhdRbLVWOeqO1lDu53haqrXqxkTSgsbm1b0PuwzkzMU5UV1pXOrPYkI2zlyjl6BvML4VSyVpCne6smukcxUamjscfUdiwpfphJutdvs4L6Dx9cJXPlsJ-cY2XzjKLYorUvTCMbAq2vjCPMdnDPJyz4cvU5K0fhDqlGu9_qzH4f6hloU4zsyjUaWH-Vqt_AwAA__8PmagU">