From 34df83c150fac5090394a2d60540c363a44f46a7 Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Wed, 27 Jun 2018 20:30:34 +0000 Subject: DR1687: When overload resolution selects a built-in operator, implicit conversions are only applied to operands of class type, and the second standard conversion sequence is not applied. When diagnosing an invalid builtin binary operator, talk about the original types rather than the converted types. If these differ by a user-defined conversion, tell the user what happened. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@335781 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Sema/SemaExprCXX.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'lib/Sema/SemaExprCXX.cpp') diff --git a/lib/Sema/SemaExprCXX.cpp b/lib/Sema/SemaExprCXX.cpp index 02cb78b9de..db47931348 100644 --- a/lib/Sema/SemaExprCXX.cpp +++ b/lib/Sema/SemaExprCXX.cpp @@ -3767,6 +3767,10 @@ Sema::PerformImplicitConversion(Expr *From, QualType ToType, const ImplicitConversionSequence &ICS, AssignmentAction Action, CheckedConversionKind CCK) { + // C++ [over.match.oper]p7: [...] operands of class type are converted [...] + if (CCK == CCK_ForBuiltinOverloadedOp && !From->getType()->isRecordType()) + return From; + switch (ICS.getKind()) { case ImplicitConversionSequence::StandardConversion: { ExprResult Res = PerformImplicitConversion(From, ToType, ICS.Standard, @@ -3826,6 +3830,12 @@ Sema::PerformImplicitConversion(Expr *From, QualType ToType, From = CastArg.get(); + // C++ [over.match.oper]p7: + // [...] the second standard conversion sequence of a user-defined + // conversion sequence is not applied. + if (CCK == CCK_ForBuiltinOverloadedOp) + return From; + return PerformImplicitConversion(From, ToType, ICS.UserDefined.After, AA_Converting, CCK); } @@ -4289,7 +4299,7 @@ Sema::PerformImplicitConversion(Expr *From, QualType ToType, // If this conversion sequence succeeded and involved implicitly converting a // _Nullable type to a _Nonnull one, complain. - if (CCK == CCK_ImplicitConversion) + if (!isCast(CCK)) diagnoseNullableToNonnullConversion(ToType, InitialFromType, From->getLocStart()); -- cgit v1.2.3