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

    <tr>
        <th>Summary</th>
        <td>
            [clang] Clang-19 regression in Wunused-but-set-variable
        </td>
    </tr>

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

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

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

<pre>
    Clang 19.1.0-rc2 incorrectly diagnoses a variable declared inside an if statement as unused if this variable is used only as the decision varaiable.

```cpp
const char* GetPtr();
bool GetBool();

struct Foo {
    operator bool() const noexcept { return true; }
};

Foo GetStruct();

void Func() {
    if (bool x = GetBool()) {  // error: variable 'x' set but not used
    }
    if (const char* x = GetPtr()) {  // error: variable 'x' set but not used
 }
    if (Foo x = GetStruct()) {  // this compiles, not sure what's the difference
    }
}
```

Clang trunk produces the same error: https://godbolt.org/z/a5sv7MTvj
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyklM-OuzYQx5_GXEaJjAlLOHBINmJPlSq1Us_GDMFbx0b2mO726StDNnSjvf2kyIkyfz4z3_FYhqCvFrFh5ZmVl0xGGp1v5rnPK17yPOtc_9m8GmmvkNf7fM93XgnQVjnvUZH5hF7Lq3UBA0iYpdeyMwg9KiM99qBt0D2CtKAHCCQJb2gJZIBoY0gOA9CowxaqAywGZ81n8qNxSaeDdjZ5ycVtz_iF8dP9fOHrR03T-o9yNhCoUXomTvCG9Dt5Jo5M1Kw4ry6dcyZZzs6ZJ9N6BvJREbTOAavuFgAAN6GX5Dx0j0hYedbhh8KJkj94pOgtkI_IijOw6nJPXl2eQInwhvTHwvuxlNnpHtpo1R33rR49ABPHpZ0PYMXlqanVHYCJlokW0HvnWXHaBGei-mCigoAEXUxd0DKBjfCofcN9F_jB3WT-VewPzKTTg_RNrSfYcqGUu03aYGDidckdokf4Z5TERHW_VXoY0KNV-EOr24-vy_X_gawbQT7av2Hyro8K15xB3nBrdiSaAitOa11X13fO0N75KxPtv0y0sgxz9duf83vWN0VfF7XMsMkrIWpe1zzPxgbz6oD8IMtjN_Ch74pe8eEoxTGXdV8VRaYbwcWBH_kLF2lj96Kr1IB8wKrk_TEv2YHjTWqzN2a-JXamQ4jY5FzwOs-M7NCEZf-FUKktJkR6CnyTAnZdvAZ24EYHClsK0mSWR2ONKC-wKLLLa_B49RiWbdUW_lrXfNdF2gWk3df4s-hN8ySPpjF2e-VuTLSJdP_aTd69Y5p1u1QemGjvxc-N-C8AAP__5mFs1Q">