From dbafc19fe0d5541263669ca9acd44b093f40e6c1 Mon Sep 17 00:00:00 2001 From: Francois Pichet Date: Thu, 9 Dec 2010 10:07:54 +0000 Subject: [PATCH] Fix PR8760: IndirectFieldDecl Type was not updated during template instantiation. llvm-svn: 121363 --- clang/lib/Sema/SemaTemplateInstantiateDecl.cpp | 3 ++- .../anonymous-union-member-initializer.cpp | 13 +++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp index e3b8cfe751ca..f98efec5ed25 100644 --- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp +++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -467,9 +467,10 @@ Decl *TemplateDeclInstantiator::VisitIndirectFieldDecl(IndirectFieldDecl *D) { NamedChain[i++] = (SemaRef.FindInstantiatedDecl(D->getLocation(), *PI, TemplateArgs)); + QualType T = cast(NamedChain[i-1])->getType(); IndirectFieldDecl* IndirectField = IndirectFieldDecl::Create(SemaRef.Context, Owner, D->getLocation(), - D->getIdentifier(), D->getType(), + D->getIdentifier(), T, NamedChain, D->getChainingSize()); diff --git a/clang/test/CodeGenCXX/anonymous-union-member-initializer.cpp b/clang/test/CodeGenCXX/anonymous-union-member-initializer.cpp index 9ba38052e172..187164e3fa91 100644 --- a/clang/test/CodeGenCXX/anonymous-union-member-initializer.cpp +++ b/clang/test/CodeGenCXX/anonymous-union-member-initializer.cpp @@ -90,3 +90,16 @@ struct S { }; }; } s; + + + //PR8760 + template + struct Foo { + Foo() : ptr(__nullptr) {} + union { + T *ptr; + }; + }; + Foo f; + +