Clang compiles with error following test case
typedef union attribute((transparent_union)) {
int *i; struct st *s;
} TU;
void bar(TU);
void foo(int *i) {
bar(i);
}
clang -c tu.c
tu.c:1:30: warning: transparent_union attribute can only be applied to a union definition; attribute ignored [-Wignored-attributes]
typedef union attribute((transparent_union)) {
^
tu.c:8:24: error: passing 'int *' to parameter of incompatible type 'TU'
void foo(int *i) { bar(i); }
^
tu.c:6:12: note: passing argument to parameter here
void bar(TU);
^
GCC compiles this test successfully.
The compilation is failed because the routine handleTransparentUnionAttr requires for the record decl to be completed. This fix provides handling of the attribute ‘transparent_union’ after parsing of union.
Why bother with the downcast? RD is a RecordDecl which inherits from TagDecl.