diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2018-06-27 20:30:34 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2018-06-27 20:30:34 +0000 |
commit | 34df83c150fac5090394a2d60540c363a44f46a7 (patch) | |
tree | dbb3a44b48637dd4dba64a0f6078fc30bcae3ee4 /lib/Sema/SemaExprCXX.cpp | |
parent | 4dc93bb1e15647d01cec2ef51f6bd53d20e7ea82 (diff) |
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
Diffstat (limited to 'lib/Sema/SemaExprCXX.cpp')
-rw-r--r-- | lib/Sema/SemaExprCXX.cpp | 12 |
1 files changed, 11 insertions, 1 deletions
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()); |