Index: cfe/trunk/lib/Sema/SemaDeclAttr.cpp =================================================================== --- cfe/trunk/lib/Sema/SemaDeclAttr.cpp +++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp @@ -3044,10 +3044,14 @@ return; } + if (FirstType->isIncompleteType()) + return; uint64_t FirstSize = S.Context.getTypeSize(FirstType); uint64_t FirstAlign = S.Context.getTypeAlign(FirstType); for (; Field != FieldEnd; ++Field) { QualType FieldType = Field->getType(); + if (FieldType->isIncompleteType()) + return; // FIXME: this isn't fully correct; we also need to test whether the // members of the union would all have the same calling convention as the // first member of the union. Checking just the size and alignment isn't Index: cfe/trunk/test/Sema/transparent-union.c =================================================================== --- cfe/trunk/test/Sema/transparent-union.c +++ cfe/trunk/test/Sema/transparent-union.c @@ -89,3 +89,12 @@ unsigned int u3; } __attribute__((aligned(8))); } __attribute__((transparent_union)); + +union pr30520v { void b; } __attribute__((transparent_union)); // expected-error {{field has incomplete type 'void'}} + +union pr30520a { int b[]; } __attribute__((transparent_union)); // expected-error {{field has incomplete type 'int []'}} + +// expected-note@+1 2 {{forward declaration of 'struct stb'}} +union pr30520s { struct stb b; } __attribute__((transparent_union)); // expected-error {{field has incomplete type 'struct stb'}} + +union pr30520s2 { int *v; struct stb b; } __attribute__((transparent_union)); // expected-error {{field has incomplete type 'struct stb'}}