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

    <tr>
        <th>Summary</th>
        <td>
            [Clang] Diagnostic for out of order initialization with designated initializer does not deal with anonymous unions correctly
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang:frontend,
            clang:diagnostics,
            confirmed
      </td>
    </tr>

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

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

<pre>
    Given the following:

```cpp
struct C {
 union {
  int a;
  const char* p;
 };
 int x;
} c = { .x = 3, .a = 3 };
```

Produces the following diagnostic: https://godbolt.org/z/Txhfa58ve

```console
warning: ISO C++ requires field designators to be specified in declaration order; field 'x' will be initialized after field '' [-Wreorder-init-list]
<source>:7:14: note: previous initialization for field 'x' is here
    7 | } c = { .x = 3, .a = 3 };
      |              ^
```

Which leaves the name for the anonymous union empty.

This is sort of related to: https://github.com/llvm/llvm-project/issues/63605 but separate enough to deal with it as it's own issue.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJykVF2P6jYQ_TWTl9GiYJOEPOQByKXqUyv1SvfZ2BPi1tip7cDu_fWVzfKxq1WlqhEimcyHz8w5ExGCPlqiDqotVH0h5jg634VRDPqv4uDUW_eLPpPFOBIOzhh30fYIfANlD-Xtvy6vPzlN1zch-llG3CE02-sbnK129slGbSMK4HdbOhsiylF4YBucHh5o-oeRsl7vJjQ9SgTep8K4eM2PHNgOF-L6_CH7DvQZ_e_eqVlS-NgiKi2O1oWoJfANjjFOIbXN9sD2R6cOzsSF80dg-5_A9t9fx0FU6zN9PRdngzPvvovw9jpD_PWP33AHbAtsi57-nrWngIMmo1BRIkZE5wNGhwfCMJHUgyaF2qIiaYQXMc3UeUUe-PY9E1jzCqzBizYm5WmroxZG_ySFYojkH3EpDKrtyw9PuchLin0xOkSo-vce-C642UsC_g34pgG-Wa4Sdusipfvk6azdHB7nXFENzn8CpAOO5OnGN2KD0CSJ_CcOMV8p8cMF1bd_4fjHqOWIhsT5nWcrTpQhJkNYZ99OqYerSOk0xbfFc_73UYeEPzgf0Q3oyYhICqP7Qhw6jvNhId0J2N6Y8-32Mnn3J8kIbK9DmCkA29e8Lis8zBEDTYlPQrJuPo6Jc0XC4EXHEXVEEVBHYE1Ad7GYCywK1XHV8lYU1C3r9XpdVauKFWN3aFe1aMthyYVYC8lZXa8lEy1VrBVi1RS6YyXjZVOuGeNlxRaq5MOgmGBLVVO7JFiVdBLaLBLypPMiH9nVvKnawogDmZC_GYxJI7KaB-9sJKuAMWC7J8djk8LD5-yg_YlydNUXvssjOszHAKsyKTA8jo46mvyF2uWKVY_9vWQm0c2ZlazhzzrMA7xtU16e2zp4VI5CEvLTqD9pIaB03pOM5q2Yven-D9VN1f4TAAD__0tAqdY">