diff options
-rw-r--r-- | lib/Sema/SemaOverload.cpp | 8 | ||||
-rw-r--r-- | test/SemaCXX/conversion-function.cpp | 14 |
2 files changed, 18 insertions, 4 deletions
diff --git a/lib/Sema/SemaOverload.cpp b/lib/Sema/SemaOverload.cpp index b6045123fe..b95b886efb 100644 --- a/lib/Sema/SemaOverload.cpp +++ b/lib/Sema/SemaOverload.cpp @@ -4535,19 +4535,19 @@ Sema::AddConversionCandidate(CXXConversionDecl *Conversion, CK_FunctionToPointerDecay, &ConversionRef, VK_RValue); - QualType CallResultType - = Conversion->getConversionType().getNonLValueExprType(Context); - if (RequireCompleteType(From->getLocStart(), CallResultType, 0)) { + QualType ConversionType = Conversion->getConversionType(); + if (RequireCompleteType(From->getLocStart(), ConversionType, 0)) { Candidate.Viable = false; Candidate.FailureKind = ovl_fail_bad_final_conversion; return; } - ExprValueKind VK = Expr::getValueKindForType(Conversion->getConversionType()); + ExprValueKind VK = Expr::getValueKindForType(ConversionType); // 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). + QualType CallResultType = ConversionType.getNonLValueExprType(Context); CallExpr Call(Context, &ConversionFn, 0, 0, CallResultType, VK, From->getLocStart()); ImplicitConversionSequence ICS = diff --git a/test/SemaCXX/conversion-function.cpp b/test/SemaCXX/conversion-function.cpp index aa47ae0f48..a7a178244c 100644 --- a/test/SemaCXX/conversion-function.cpp +++ b/test/SemaCXX/conversion-function.cpp @@ -378,3 +378,17 @@ namespace PR9336 { generic_list<generic_list<int> > l; array<array<int> > a = l; } + +namespace PR8800 { + struct A; + struct C { + operator A&(); + }; + void f() { + C c; + A& a1(c); + A& a2 = c; + A& a3 = static_cast<A&>(c); + A& a4 = (A&)c; + } +} |