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

    <tr>
        <th>Summary</th>
        <td>
            clang's bad register type error points to register keyword instead of type name
        </td>
    </tr>

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

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

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

<pre>
    Reported / discovered by https://discourse.llvm.org/t/frontend-how-to-use-register-union-or-struct-in-c/81392.

https://godbolt.org/z/fx6M7KrW9

```
typedef union Test {
    int i;
} Test;

register Test t asm ("x21");
```
Errors with:
```
<source>:5:22: error: size of register 'x21' does not match variable size
    5 | register Test t asm ("x21");
      |                      ^
<source>:5:1: error: bad type for named register variable
    5 | register Test t asm ("x21");
 | ^
2 errors generated.
Compiler returned: 1
```
The second error:
```
<source>:5:1: error: bad type for named register variable
    5 | register Test t asm ("x21");
      | ^
```
Points to the storage specifier not to the type name, which is confusing if you are not laser focused on the exact meaning of "type" here.

It should be:
```
<source>:5:1: error: bad type for named register variable
    5 | register Test t asm ("x21");
      | ^
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzUVVGL4zYQ_jXjl8GLPY7j-MEPuc0GSimU9qDPsjS21XOkIMnZzf36Im3OacoWWgqFE4mSaPTp-76ZiSy816Nh7qD-BPUhE0uYrOsO4qLVr2ctv3AIWW_VtfuFz9YFVgh0RKW9tBd2rLC_4hTC2UO1BzoCHVNscZ6f5vlyerJuBDoGoOPgrAlsVD7Z1zzYfPGcOx61D-zyxWhrcutyH9wiQ65NLoGOu7Jq6QmKAxT79_mRbLSqt3O4sXyNLG_bn5of3W_tn0GwLW6v9DNcz6x4wESKn9kHhObTewwRUZuAGqrbCjSHtOe-kOZv0t_xAYU_IdAOiN6oBCKg9o545H9xzjqPrzpM0clHW6B69nZxkqF6gWpfQ7UngmqPHLHxi9dfGe2Aqw6gJjE3qCx7NDbgSQQ54UU4LfqZE-TuskZonvHf2MA0IurDAfXL34ovH7T3QmEsAg7WoREnVncd39T-J6ERsMqhd2KPIxt2IrC6ddSzPZ31zA4dh8UZVlFb-WE9Pk-MnqU1anXxT-v2P1tfa3Qvx6PEn602wWOwGKKpYJ0YGf2ZpR40u9Q4t2ASGkUCPePrpOWE2qO0Zli8NiPqAa92QeE4oWbh2eFg5eJZoTXpDH4TMuCJhYkIOyAQxXOBCCd2_PDv_iGgn-wyK-z5u0xxprpKtVUrMu7KhpqyKZvdJps62Su54bIUZa12vOFdRVuSshgaJcpt22S6o4I2RRvf9ZY2T7ut3Mq-Gdqdqje1LGBT8Enoeb1XM-39wl1ZtE2zzWbR8-zTRU4kZ2HGKLs-ZK6LgLxfRg-bYtY--PsRQYeZu9v2xqfcrblISUxpxfPaNGv0C19frVOojQ8sVCzt2i_Z4ubuL1e1DtPSP0l7AjpG_ttHfnb2d5bxCZH8eKDjzdKloz8CAAD__2uR9ks">