We may need to instantiate a class template specialization as part of a derived-to-base pointer case

llvm-svn: 85532
This commit is contained in:
Douglas Gregor 2009-10-29 23:08:22 +00:00
parent d4b78d38d4
commit e6fb91f2cb
2 changed files with 11 additions and 2 deletions

View File

@ -999,6 +999,7 @@ bool Sema::IsPointerConversion(Expr *From, QualType FromType, QualType ToType,
// here. That is handled by CheckPointerConversion.
if (getLangOptions().CPlusPlus &&
FromPointeeType->isRecordType() && ToPointeeType->isRecordType() &&
!RequireCompleteType(From->getLocStart(), FromPointeeType, PDiag()) &&
IsDerivedFrom(FromPointeeType, ToPointeeType)) {
ConvertedType = BuildSimilarlyQualifiedPointerType(FromTypePtr,
ToPointeeType,

View File

@ -96,7 +96,6 @@ struct FunctionalCast1 {
template struct FunctionalCast1<int, float>;
template struct FunctionalCast1<A, int>; // expected-note{{instantiation}}
#if 0
// Generates temporaries, which we cannot handle yet.
template<int N, long M>
struct FunctionalCast2 {
@ -106,4 +105,13 @@ struct FunctionalCast2 {
};
template struct FunctionalCast2<1, 3>;
#endif
// ---------------------------------------------------------------------
// implicit casting
// ---------------------------------------------------------------------
template<typename T>
struct Derived2 : public Base { };
void test_derived_to_base(Base *&bp, Derived2<int> *dp) {
bp = dp;
}