From 25edf4302f07a59a49324731e153977806ecb131 Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Fri, 5 Nov 2010 23:22:45 +0000 Subject: [PATCH] When searching for an instantiated declaration requires instantiation of its parent context, be sure to update the parent-context pointer after instantiation. Fixes two anonymous-union instantiation issues in . llvm-svn: 118313 --- .../lib/Sema/SemaTemplateInstantiateDecl.cpp | 2 ++ clang/test/SemaTemplate/anonymous-union.cpp | 21 +++++++++++++++++++ 2 files changed, 23 insertions(+) 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; + } +}