diff --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp index 6e352e71ef65..a594e678d6ce 100644 --- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp +++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -2753,6 +2753,8 @@ NamedDecl *Sema::FindInstantiatedDecl(SourceLocation Loc, NamedDecl *D, if (!Tag->isBeingDefined() && RequireCompleteType(Loc, T, diag::err_incomplete_type)) return 0; + + ParentDC = Tag->getDecl(); } } diff --git a/clang/test/SemaTemplate/anonymous-union.cpp b/clang/test/SemaTemplate/anonymous-union.cpp index 59d1f25a4fd2..97ecd6e60cca 100644 --- a/clang/test/SemaTemplate/anonymous-union.cpp +++ b/clang/test/SemaTemplate/anonymous-union.cpp @@ -17,3 +17,24 @@ struct T1 : public T0, public T { struct A : public T0 { }; void f1(T1 *S) { S->f0(); } // expected-note{{instantiation of member function}} + +namespace rdar8635664 { + template + struct X { + struct inner; + + struct inner { + union { + int x; + float y; + }; + + typedef T type; + }; + }; + + void test() { + X::inner i; + i.x = 0; + } +}