aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaInit.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2010-11-08 15:20:28 +0000
committerDouglas Gregor <dgregor@apple.com>2010-11-08 15:20:28 +0000
commit3afb97700200f629d6036e437267af9c1fd37c90 (patch)
treec49129ce83712b55084ed683a1c2b367dfbc100a /lib/Sema/SemaInit.cpp
parent94c8022573b2f7da5124558a8d0597b0e8fbb381 (diff)
When attempting reference binding to an overloaded function, also
consider that we might be trying to bind a reference to a class type, which involves a constructor call. Fixes PR7425. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@118407 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaInit.cpp')
-rw-r--r--lib/Sema/SemaInit.cpp23
1 files changed, 13 insertions, 10 deletions
diff --git a/lib/Sema/SemaInit.cpp b/lib/Sema/SemaInit.cpp
index bee2ba46a8..f45893df86 100644
--- a/lib/Sema/SemaInit.cpp
+++ b/lib/Sema/SemaInit.cpp
@@ -2511,18 +2511,17 @@ static void TryReferenceInitialization(Sema &S,
// type of the resulting function.
if (S.Context.getCanonicalType(T2) == S.Context.OverloadTy) {
DeclAccessPair Found;
- FunctionDecl *Fn = S.ResolveAddressOfOverloadedFunction(Initializer,
- T1,
- false,
- Found);
- if (!Fn) {
+ if (FunctionDecl *Fn = S.ResolveAddressOfOverloadedFunction(Initializer,
+ T1,
+ false,
+ Found)) {
+ Sequence.AddAddressOverloadResolutionStep(Fn, Found);
+ cv2T2 = Fn->getType();
+ T2 = cv2T2.getUnqualifiedType();
+ } else if (!T1->isRecordType()) {
Sequence.SetFailed(InitializationSequence::FK_AddressOfOverloadFailed);
return;
}
-
- Sequence.AddAddressOverloadResolutionStep(Fn, Found);
- cv2T2 = Fn->getType();
- T2 = cv2T2.getUnqualifiedType();
}
// Compute some basic properties of the types and the initializer.
@@ -2604,7 +2603,9 @@ static void TryReferenceInitialization(Sema &S,
// We handled the function type stuff above.
if (!((isLValueRef && T1Quals.hasConst() && !T1Quals.hasVolatile()) ||
(isRValueRef && InitCategory.isRValue()))) {
- if (ConvOvlResult && !Sequence.getFailedCandidateSet().empty())
+ if (S.Context.getCanonicalType(T2) == S.Context.OverloadTy)
+ Sequence.SetFailed(InitializationSequence::FK_AddressOfOverloadFailed);
+ else if (ConvOvlResult && !Sequence.getFailedCandidateSet().empty())
Sequence.SetOverloadFailure(
InitializationSequence::FK_ReferenceInitOverloadFailed,
ConvOvlResult);
@@ -2706,6 +2707,8 @@ static void TryReferenceInitialization(Sema &S,
Sequence.SetOverloadFailure(
InitializationSequence::FK_ReferenceInitOverloadFailed,
ConvOvlResult);
+ else if (S.Context.getCanonicalType(T2) == S.Context.OverloadTy)
+ Sequence.SetFailed(InitializationSequence::FK_AddressOfOverloadFailed);
else
Sequence.SetFailed(InitializationSequence::FK_ReferenceInitFailed);
return;