@@ -1881,8 +1881,15 @@ ExprResult Sema::PerformImplicitConversion(Expr *From, QualType ToType,
18811881 return PerformImplicitConversion(From, ToType, ICS, Action);
18821882}
18831883
1884- bool Sema::IsFunctionConversion(QualType FromType, QualType ToType,
1885- QualType &ResultTy) {
1884+ bool Sema::TryFunctionConversion(QualType FromType, QualType ToType,
1885+ QualType &ResultTy) const {
1886+ bool Changed = IsFunctionConversion(FromType, ToType);
1887+ if (Changed)
1888+ ResultTy = ToType;
1889+ return Changed;
1890+ }
1891+
1892+ bool Sema::IsFunctionConversion(QualType FromType, QualType ToType) const {
18861893 if (Context.hasSameUnqualifiedType(FromType, ToType))
18871894 return false;
18881895
@@ -1993,7 +2000,6 @@ bool Sema::IsFunctionConversion(QualType FromType, QualType ToType,
19932000 assert(QualType(FromFn, 0).isCanonical());
19942001 if (QualType(FromFn, 0) != CanTo) return false;
19952002
1996- ResultTy = ToType;
19972003 return true;
19982004}
19992005
@@ -2232,11 +2238,10 @@ static bool IsStandardConversion(Sema &S, Expr* From, QualType ToType,
22322238 // we can sometimes resolve &foo<int> regardless of ToType, so check
22332239 // if the type matches (identity) or we are converting to bool
22342240 if (!S.Context.hasSameUnqualifiedType(
2235- S.ExtractUnqualifiedFunctionType(ToType), FromType)) {
2236- QualType resultTy;
2241+ S.ExtractUnqualifiedFunctionType(ToType), FromType)) {
22372242 // if the function type matches except for [[noreturn]], it's ok
22382243 if (!S.IsFunctionConversion(FromType,
2239- S.ExtractUnqualifiedFunctionType(ToType), resultTy ))
2244+ S.ExtractUnqualifiedFunctionType(ToType)))
22402245 // otherwise, only a boolean conversion is standard
22412246 if (!ToType->isBooleanType())
22422247 return false;
@@ -2476,7 +2481,7 @@ static bool IsStandardConversion(Sema &S, Expr* From, QualType ToType,
24762481 // The third conversion can be a function pointer conversion or a
24772482 // qualification conversion (C++ [conv.fctptr], [conv.qual]).
24782483 bool ObjCLifetimeConversion;
2479- if (S.IsFunctionConversion (FromType, ToType, FromType)) {
2484+ if (S.TryFunctionConversion (FromType, ToType, FromType)) {
24802485 // Function pointer conversions (removing 'noexcept') including removal of
24812486 // 'noreturn' (Clang extension).
24822487 SCS.Third = ICK_Function_Conversion;
@@ -5033,7 +5038,6 @@ Sema::CompareReferenceRelationship(SourceLocation Loc,
50335038 // Check for standard conversions we can apply to pointers: derived-to-base
50345039 // conversions, ObjC pointer conversions, and function pointer conversions.
50355040 // (Qualification conversions are checked last.)
5036- QualType ConvertedT2;
50375041 if (UnqualT1 == UnqualT2) {
50385042 // Nothing to do.
50395043 } else if (isCompleteType(Loc, OrigT2) &&
@@ -5044,7 +5048,7 @@ Sema::CompareReferenceRelationship(SourceLocation Loc,
50445048 Context.canBindObjCObjectType(UnqualT1, UnqualT2))
50455049 Conv |= ReferenceConversions::ObjC;
50465050 else if (UnqualT2->isFunctionType() &&
5047- IsFunctionConversion(UnqualT2, UnqualT1, ConvertedT2 )) {
5051+ IsFunctionConversion(UnqualT2, UnqualT1)) {
50485052 Conv |= ReferenceConversions::Function;
50495053 // No need to check qualifiers; function types don't have them.
50505054 return Ref_Compatible;
@@ -13426,9 +13430,8 @@ class AddressOfFunctionResolver {
1342613430
1342713431private:
1342813432 bool candidateHasExactlyCorrectType(const FunctionDecl *FD) {
13429- QualType Discard;
1343013433 return Context.hasSameUnqualifiedType(TargetFunctionType, FD->getType()) ||
13431- S.IsFunctionConversion(FD->getType(), TargetFunctionType, Discard );
13434+ S.IsFunctionConversion(FD->getType(), TargetFunctionType);
1343213435 }
1343313436
1343413437 /// \return true if A is considered a better overload candidate for the
0 commit comments