From: Douglas Gregor Date: Thu, 29 Oct 2009 23:08:22 +0000 (+0000) Subject: We may need to instantiate a class template specialization as part of a derived-to... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2685eab9d36a3568b5d58fba13f0ecef6a611cf9;p=clang We may need to instantiate a class template specialization as part of a derived-to-base pointer case git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85532 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaOverload.cpp b/lib/Sema/SemaOverload.cpp index bdaf6e4d92..946e28269e 100644 --- a/lib/Sema/SemaOverload.cpp +++ b/lib/Sema/SemaOverload.cpp @@ -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, diff --git a/test/SemaTemplate/instantiate-cast.cpp b/test/SemaTemplate/instantiate-cast.cpp index 6b3fc6e125..c3c318f36d 100644 --- a/test/SemaTemplate/instantiate-cast.cpp +++ b/test/SemaTemplate/instantiate-cast.cpp @@ -96,7 +96,6 @@ struct FunctionalCast1 { template struct FunctionalCast1; template struct FunctionalCast1; // expected-note{{instantiation}} -#if 0 // Generates temporaries, which we cannot handle yet. template struct FunctionalCast2 { @@ -106,4 +105,13 @@ struct FunctionalCast2 { }; template struct FunctionalCast2<1, 3>; -#endif + +// --------------------------------------------------------------------- +// implicit casting +// --------------------------------------------------------------------- +template +struct Derived2 : public Base { }; + +void test_derived_to_base(Base *&bp, Derived2 *dp) { + bp = dp; +}