From: Douglas Gregor Date: Sat, 13 Nov 2010 19:36:57 +0000 (+0000) Subject: When we're type-checking the result of calling a conversion function X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7d14d389f0539545715e756629127c1fe5a4773a;p=clang When we're type-checking the result of calling a conversion function (while computing user conversion sequences), make sure that a result of class type is a complete class type. Had we gone through ActOnCallExpr, this would have happened when we built the CallExpr. Fixes PR8425. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@119005 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaOverload.cpp b/lib/Sema/SemaOverload.cpp index d82f885408..f8c6f6971d 100644 --- a/lib/Sema/SemaOverload.cpp +++ b/lib/Sema/SemaOverload.cpp @@ -3877,11 +3877,18 @@ Sema::AddConversionCandidate(CXXConversionDecl *Conversion, CK_FunctionToPointerDecay, &ConversionRef, VK_RValue); + QualType CallResultType + = Conversion->getConversionType().getNonLValueExprType(Context); + if (RequireCompleteType(From->getLocStart(), CallResultType, 0)) { + Candidate.Viable = false; + Candidate.FailureKind = ovl_fail_bad_final_conversion; + return; + } + // Note that it is safe to allocate CallExpr on the stack here because // there are 0 arguments (i.e., nothing is allocated using ASTContext's // allocator). - CallExpr Call(Context, &ConversionFn, 0, 0, - Conversion->getConversionType().getNonLValueExprType(Context), + CallExpr Call(Context, &ConversionFn, 0, 0, CallResultType, From->getLocStart()); ImplicitConversionSequence ICS = TryCopyInitialization(*this, &Call, ToType, diff --git a/test/SemaTemplate/instantiate-complete.cpp b/test/SemaTemplate/instantiate-complete.cpp index 91d4d32707..4b27da7349 100644 --- a/test/SemaTemplate/instantiate-complete.cpp +++ b/test/SemaTemplate/instantiate-complete.cpp @@ -126,3 +126,23 @@ namespace pr7199 { template class B; // expected-note {{in instantiation}} } + +namespace PR8425 { + template + class BaseT {}; + + template + class DerivedT : public BaseT {}; + + template + class FromT { + public: + operator DerivedT() const { return DerivedT(); } + }; + + void test() { + FromT ft; + BaseT bt(ft); + } +} +