]> granicus.if.org Git - clang/commitdiff
We may need to instantiate a class template specialization as part of a derived-to...
authorDouglas Gregor <dgregor@apple.com>
Thu, 29 Oct 2009 23:08:22 +0000 (23:08 +0000)
committerDouglas Gregor <dgregor@apple.com>
Thu, 29 Oct 2009 23:08:22 +0000 (23:08 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85532 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaOverload.cpp
test/SemaTemplate/instantiate-cast.cpp

index bdaf6e4d925c42f799a0733445b91ace3971818b..946e28269eb6efd48b473c87b7de718a53fbaeef 100644 (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,
index 6b3fc6e1253409e61ff5c4fe34d77155df3eeaa1..c3c318f36d5d3832dcf698de97e7414e8f3ee9f3 100644 (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;
+}