| Issue |
184954
|
| Summary |
[clang]Clang rejects GNU attributes on bit-field declarators (GCC and EDG accept)
|
| Labels |
clang
|
| Assignees |
|
| Reporter |
Attacker23
|
When a GNU attribute is placed **after the declarator** and directly before a bit-field width, Clang rejects the code, while putting the same attribute in other positions works, and GCC/EDG accept it.
```cpp
struct S {
//OK:
int t [[gnu::aligned(16)]];
int v [[gnu::aligned(16)]] : 4;
int b [[gnu::packed]] : 4;
int s __attribute__((aligned(16)));
__attribute__((aligned(16))) int z : 4;
//error:
int a __attribute__((packed)) : 4;
int u __attribute__((aligned(16))) : 4;
};
```
https://godbolt.org/z/4v6vM91ro
In other words, any declaration of the form:
```cpp
int u __attribute__((...)) : N;
```
fails to parse in Clang, while:
- attribute before the type (`__attribute__((...)) int z : 4;`), or
- attribute on a non–bit-field member (`int s __attribute__((aligned(16)));`)
is accepted. GCC and EDG accept all of the above forms.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs