forked from OSchip/llvm-project
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:
parent
b74b1038bb
commit
1da2225786
|
@ -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();
|
||||
|
|
|
@ -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>;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue