diff options
| -rw-r--r-- | clang/lib/Sema/SemaInit.cpp | 8 | ||||
| -rw-r--r-- | clang/lib/Sema/SemaOverload.cpp | 3 | ||||
| -rw-r--r-- | clang/test/SemaTemplate/instantiate-complete.cpp | 20 | 
3 files changed, 26 insertions, 5 deletions
diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp index 0360b3d9656..b2f416ca374 100644 --- a/clang/lib/Sema/SemaInit.cpp +++ b/clang/lib/Sema/SemaInit.cpp @@ -2245,11 +2245,11 @@ static OverloadingResult TryRefInitWithConversionFunction(Sema &S,    bool AllowExplicit = Kind.getKind() == InitializationKind::IK_Direct;    const RecordType *T1RecordType = 0; -  if (AllowRValues && (T1RecordType = T1->getAs<RecordType>())) { +  if (AllowRValues && (T1RecordType = T1->getAs<RecordType>()) && +      !S.RequireCompleteType(Kind.getLocation(), T1, 0)) {      // The type we're converting to is a class type. Enumerate its constructors      // to see if there is a suitable conversion.      CXXRecordDecl *T1RecordDecl = cast<CXXRecordDecl>(T1RecordType->getDecl()); -          DeclarationName ConstructorName        = S.Context.DeclarationNames.getCXXConstructorName(                             S.Context.getCanonicalType(T1).getUnqualifiedType()); @@ -2281,7 +2281,9 @@ static OverloadingResult TryRefInitWithConversionFunction(Sema &S,      }        } -  if (const RecordType *T2RecordType = T2->getAs<RecordType>()) { +  const RecordType *T2RecordType = 0; +  if ((T2RecordType = T2->getAs<RecordType>()) && +      !S.RequireCompleteType(Kind.getLocation(), T2, 0)) {      // The type we're converting from is a class type, enumerate its conversion      // functions.      CXXRecordDecl *T2RecordDecl = cast<CXXRecordDecl>(T2RecordType->getDecl()); diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp index 531ca39a996..dec9854c72e 100644 --- a/clang/lib/Sema/SemaOverload.cpp +++ b/clang/lib/Sema/SemaOverload.cpp @@ -2289,8 +2289,7 @@ Sema::CompareReferenceRelationship(SourceLocation Loc,    //   T1 is a base class of T2.    if (UnqualT1 == UnqualT2)      DerivedToBase = false; -  else if (!RequireCompleteType(Loc, OrigT1, PDiag()) && -           !RequireCompleteType(Loc, OrigT2, PDiag()) && +  else if (!RequireCompleteType(Loc, OrigT2, PDiag()) &&             IsDerivedFrom(UnqualT2, UnqualT1))      DerivedToBase = true;    else diff --git a/clang/test/SemaTemplate/instantiate-complete.cpp b/clang/test/SemaTemplate/instantiate-complete.cpp index d854c9e6aac..a2cb0491732 100644 --- a/clang/test/SemaTemplate/instantiate-complete.cpp +++ b/clang/test/SemaTemplate/instantiate-complete.cpp @@ -99,3 +99,23 @@ namespace TemporaryObjectCopy {    template void f(int);  } + +namespace PR7080 { +  template <class T, class U> +  class X +  { +    typedef char true_t; +    class false_t { char dummy[2]; }; +    static true_t dispatch(U); +    static false_t dispatch(...); +    static T trigger(); +  public: +    enum { value = sizeof(dispatch(trigger())) == sizeof(true_t) }; +  }; + +  template <class T> +  class rv : public T +  { }; + +  bool x = X<int, rv<int>&>::value; +}  | 

