This is an update of this patch: https://reviews.llvm.org/D25824
I cannot seem to get that review to update with my diff. This first patch removes the dependency on isParsing and switches to isBeingDefined. In order to get that to work, changing where attributes where changed was necessary.
Original description below:
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.