Make sure that we don't visit redeclarations of nested classes while

instantiating class members as part of an explicit
instantiation. Addresses a compilation problem in
Boost.Serialization.

llvm-svn: 101725
This commit is contained in:
Douglas Gregor 2010-04-18 18:11:38 +00:00
parent b74b1038bb
commit 1da2225786
2 changed files with 21 additions and 1 deletions

View File

@ -1446,7 +1446,10 @@ Sema::InstantiateClassMembers(SourceLocation PointOfInstantiation,
}
}
} else if (CXXRecordDecl *Record = dyn_cast<CXXRecordDecl>(*D)) {
if (Record->isInjectedClassName())
// Always skip the injected-class-name, along with any
// redeclarations of nested classes, since both would cause us
// to try to instantiate the members of a class twice.
if (Record->isInjectedClassName() || Record->getPreviousDeclaration())
continue;
MemberSpecializationInfo *MSInfo = Record->getMemberSpecializationInfo();

View File

@ -27,3 +27,20 @@ template union X0<float>::Inner; // expected-error{{duplicate explicit instantia
template float X0<float>::value; // expected-note{{previous explicit instantiation}}
template float X0<float>::value; // expected-error{{duplicate explicit instantiation}}
// Make sure that we don't get tricked by redeclarations of nested classes.
namespace NestedClassRedecls {
template<typename T>
struct X {
struct Nested;
friend struct Nested;
struct Nested {
Nested() {}
} nested;
};
X<int> xi;
template struct X<int>;
}