Fix a codegen crash when a class template has a constructor that does member initialization of an anonymous union.

llvm-svn: 80826
This commit is contained in:
Anders Carlsson 2009-09-02 19:17:55 +00:00
parent b92c73a02a
commit 2e56cc6e6c
2 changed files with 21 additions and 9 deletions

View File

@ -242,17 +242,19 @@ Decl *TemplateDeclInstantiator::VisitFieldDecl(FieldDecl *D) {
D->getTypeSpecStartLoc(),
D->getAccess(),
0);
if (Field) {
if (Invalid)
Field->setInvalidDecl();
if (!Field)
return 0;
if (Invalid)
Field->setInvalidDecl();
if (!Field->getDeclName()) {
// Keep track of where this decl came from.
SemaRef.Context.setInstantiatedFromUnnamedFieldDecl(Field, D);
}
Owner->addDecl(Field);
if (!Field->getDeclName()) {
// Keep track of where this decl came from.
SemaRef.Context.setInstantiatedFromUnnamedFieldDecl(Field, D);
}
Field->setImplicit(D->isImplicit());
Owner->addDecl(Field);
return Field;
}

View File

@ -0,0 +1,10 @@
// RUN: clang-cc -emit-llvm -o %t %s
template <typename T>
class A
{
union { void *d; };
A() : d(0) { }
};
A<int> a0;