Fix template instantiation for __builtin_offfsetof expressions that refer to members of anonymous structs/unions

llvm-svn: 102551
This commit is contained in:
Douglas Gregor 2010-04-28 22:43:14 +00:00
parent a8a9d6a1f0
commit ea679ec125
2 changed files with 19 additions and 0 deletions

View File

@ -4219,6 +4219,9 @@ TreeTransform<Derived>::TransformOffsetOfExpr(OffsetOfExpr *E) {
case Node::Identifier:
Comp.isBrackets = false;
Comp.U.IdentInfo = ON.getFieldName();
if (!Comp.U.IdentInfo)
continue;
break;
}

View File

@ -19,4 +19,20 @@ namespace PR5880 {
struct B { ArrayOfHasM a; };
A<B> x;
A<HasM> x2; // expected-note{{in instantiation of}}
template<typename T>
struct AnonymousUnion {
union {
int i;
float f;
};
};
template<typename T>
void test_anon_union() {
int array1[__builtin_offsetof(AnonymousUnion<T>, f) == 0? 1 : -1];
int array2[__builtin_offsetof(AnonymousUnion<int>, f) == 0? 1 : -1];
}
template void test_anon_union<int>();
}