Issue 109777
Summary clang does not support union or struct types for "register" variables
Labels clang
Assignees
Reporter DavidSpickett
    Originally reported by https://discourse.llvm.org/t/frontend-how-to-use-register-union-or-struct-in-c/81392.

https://godbolt.org/z/bz8nM1E9x

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

register Test t asm ("x21");

typedef struct Test2 {
    int i;
} Test2;

register Test t2 asm ("x22");

register int t3 asm ("w23");
register int *t4 asm ("x24");
```
Clang does not allow the first 2, the union and struct, despite their sizeof being correct for the register chosen.
```
<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");
      | ^
<source>:11:1: error: bad type for named register variable
   11 | register Test t2 asm ("w22");
      | ^
```
GCC allows all of them.

It appears that types have to be explicitly added, as was done for pointers https://github.com/llvm/llvm-project/commit/2e31e4e47b09ca5e889e7470e5ae372348661692.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to