aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaOverload.cpp
diff options
context:
space:
mode:
authorSebastian Redl <sebastian.redl@getdesigned.at>2011-09-24 17:48:00 +0000
committerSebastian Redl <sebastian.redl@getdesigned.at>2011-09-24 17:48:00 +0000
commit14b0c194b356a1204d081765b3e6699687bed97c (patch)
tree8bd766140d426e0fa68e81a88f130bc646b7aaa6 /lib/Sema/SemaOverload.cpp
parent8713d4e874f2adc2928ebfb86c845574a14e3b3e (diff)
Give InitListChecker a verification-only mode, where it neither emits diagnostics nor
builds a semantic (structured) initializer list, just reports on whether it can match the given list to the target type. Use this mode for doing init list checking in the initial step of initialization, which will eventually allow us to do overload resolution based on the outcome. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@140457 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaOverload.cpp')
-rw-r--r--lib/Sema/SemaOverload.cpp34
1 files changed, 19 insertions, 15 deletions
diff --git a/lib/Sema/SemaOverload.cpp b/lib/Sema/SemaOverload.cpp
index 9a802226e2..513990e177 100644
--- a/lib/Sema/SemaOverload.cpp
+++ b/lib/Sema/SemaOverload.cpp
@@ -909,20 +909,22 @@ Sema::TryImplicitConversion(Expr *From, QualType ToType,
/// explicit user-defined conversions are permitted.
ExprResult
Sema::PerformImplicitConversion(Expr *From, QualType ToType,
- AssignmentAction Action, bool AllowExplicit) {
+ AssignmentAction Action, bool AllowExplicit,
+ bool Diagnose) {
ImplicitConversionSequence ICS;
- return PerformImplicitConversion(From, ToType, Action, AllowExplicit, ICS);
+ return PerformImplicitConversion(From, ToType, Action, AllowExplicit, ICS,
+ Diagnose);
}
ExprResult
Sema::PerformImplicitConversion(Expr *From, QualType ToType,
AssignmentAction Action, bool AllowExplicit,
- ImplicitConversionSequence& ICS) {
+ ImplicitConversionSequence& ICS,
+ bool Diagnose) {
// Objective-C ARC: Determine whether we will allow the writeback conversion.
bool AllowObjCWritebackConversion
= getLangOptions().ObjCAutoRefCount &&
(Action == AA_Passing || Action == AA_Sending);
-
ICS = clang::TryImplicitConversion(*this, From, ToType,
/*SuppressUserConversions=*/false,
@@ -930,6 +932,8 @@ Sema::PerformImplicitConversion(Expr *From, QualType ToType,
/*InOverloadResolution=*/false,
/*CStyle=*/false,
AllowObjCWritebackConversion);
+ if (!Diagnose && ICS.isFailure())
+ return ExprError();
return PerformImplicitConversion(From, ToType, ICS, Action);
}
@@ -8386,18 +8390,18 @@ Sema::BuildOverloadedCallExpr(Scope *S, Expr *Fn, UnresolvedLookupExpr *ULE,
// BuildRecoveryCallExpr diagnoses the error itself, so we just bail
// out if it fails.
if (CandidateSet.empty()) {
- // In Microsoft mode, if we are inside a template class member function then
- // create a type dependent CallExpr. The goal is to postpone name lookup
+ // In Microsoft mode, if we are inside a template class member function then
+ // create a type dependent CallExpr. The goal is to postpone name lookup
// to instantiation time to be able to search into type dependent base
- // classes.
- if (getLangOptions().MicrosoftExt && CurContext->isDependentContext() &&
- isa<CXXMethodDecl>(CurContext)) {
- CallExpr *CE = new (Context) CallExpr(Context, Fn, Args, NumArgs,
- Context.DependentTy, VK_RValue,
- RParenLoc);
- CE->setTypeDependent(true);
- return Owned(CE);
- }
+ // classes.
+ if (getLangOptions().MicrosoftExt && CurContext->isDependentContext() &&
+ isa<CXXMethodDecl>(CurContext)) {
+ CallExpr *CE = new (Context) CallExpr(Context, Fn, Args, NumArgs,
+ Context.DependentTy, VK_RValue,
+ RParenLoc);
+ CE->setTypeDependent(true);
+ return Owned(CE);
+ }
return BuildRecoveryCallExpr(*this, S, Fn, ULE, LParenLoc, Args, NumArgs,
RParenLoc, /*EmptyLookup=*/true);
}