From 091fffeed8971a577bc3c8057c1ec40015a22775 Mon Sep 17 00:00:00 2001 From: Sebastian Redl Date: Sun, 16 Oct 2011 18:19:06 +0000 Subject: [PATCH] Drop the Diagnose parameter from Sema::PerformImplicitConversion again and instead use TryImplicitConversion in CheckSingleAssignmentConstraints when that function is in no-diagnostics mode. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@142143 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Sema/Sema.h | 6 ++---- lib/Sema/SemaExpr.cpp | 20 +++++++++++++++++--- lib/Sema/SemaOverload.cpp | 11 +++-------- 3 files changed, 22 insertions(+), 15 deletions(-) diff --git a/include/clang/Sema/Sema.h b/include/clang/Sema/Sema.h index 22d5db2944..775dc1283d 100644 --- a/include/clang/Sema/Sema.h +++ b/include/clang/Sema/Sema.h @@ -5652,13 +5652,11 @@ public: ExprResult PerformImplicitConversion(Expr *From, QualType ToType, AssignmentAction Action, - bool AllowExplicit = false, - bool Diagnose = true); + bool AllowExplicit = false); ExprResult PerformImplicitConversion(Expr *From, QualType ToType, AssignmentAction Action, bool AllowExplicit, - ImplicitConversionSequence& ICS, - bool Diagnose = true); + ImplicitConversionSequence& ICS); ExprResult PerformImplicitConversion(Expr *From, QualType ToType, const ImplicitConversionSequence& ICS, AssignmentAction Action, diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index 60f84183fa..79db724f1a 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -5540,9 +5540,23 @@ Sema::CheckSingleAssignmentConstraints(QualType LHSType, ExprResult &RHS, // C++ 5.17p3: If the left operand is not of class type, the // expression is implicitly converted (C++ 4) to the // cv-unqualified type of the left operand. - ExprResult Res = PerformImplicitConversion(RHS.get(), - LHSType.getUnqualifiedType(), - AA_Assigning, Diagnose); + ExprResult Res; + if (Diagnose) { + Res = PerformImplicitConversion(RHS.get(), LHSType.getUnqualifiedType(), + AA_Assigning); + } else { + ImplicitConversionSequence ICS = + TryImplicitConversion(RHS.get(), LHSType.getUnqualifiedType(), + /*SuppressUserConversions=*/false, + /*AllowExplicit=*/false, + /*InOverloadResolution=*/false, + /*CStyle=*/false, + /*AllowObjCWritebackConversion=*/false); + if (ICS.isFailure()) + return Incompatible; + Res = PerformImplicitConversion(RHS.get(), LHSType.getUnqualifiedType(), + ICS, AA_Assigning); + } if (Res.isInvalid()) return Incompatible; Sema::AssignConvertType result = Compatible; diff --git a/lib/Sema/SemaOverload.cpp b/lib/Sema/SemaOverload.cpp index b0dd5e280e..440c2d1edd 100644 --- a/lib/Sema/SemaOverload.cpp +++ b/lib/Sema/SemaOverload.cpp @@ -912,18 +912,15 @@ Sema::TryImplicitConversion(Expr *From, QualType ToType, /// explicit user-defined conversions are permitted. ExprResult Sema::PerformImplicitConversion(Expr *From, QualType ToType, - AssignmentAction Action, bool AllowExplicit, - bool Diagnose) { + AssignmentAction Action, bool AllowExplicit) { ImplicitConversionSequence ICS; - return PerformImplicitConversion(From, ToType, Action, AllowExplicit, ICS, - Diagnose); + return PerformImplicitConversion(From, ToType, Action, AllowExplicit, ICS); } ExprResult Sema::PerformImplicitConversion(Expr *From, QualType ToType, AssignmentAction Action, bool AllowExplicit, - ImplicitConversionSequence& ICS, - bool Diagnose) { + ImplicitConversionSequence& ICS) { // Objective-C ARC: Determine whether we will allow the writeback conversion. bool AllowObjCWritebackConversion = getLangOptions().ObjCAutoRefCount && @@ -935,8 +932,6 @@ Sema::PerformImplicitConversion(Expr *From, QualType ToType, /*InOverloadResolution=*/false, /*CStyle=*/false, AllowObjCWritebackConversion); - if (!Diagnose && ICS.isFailure()) - return ExprError(); return PerformImplicitConversion(From, ToType, ICS, Action); } -- 2.40.0