aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaInit.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2010-03-07 23:17:44 +0000
committerDouglas Gregor <dgregor@apple.com>2010-03-07 23:17:44 +0000
commita1a9f035852e35ed88f4902a855eb952cf08bebb (patch)
treef27f57269912efa4648e9c3d109ab50cbe054836 /lib/Sema/SemaInit.cpp
parent6b82f642ba3530b6201a6632ae8d317f836af7e2 (diff)
Reference binding via user-defined conversion can compute a binding
that is not reference-related (because it requires another implicit conversion to which we can find). Fixes PR6483. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97922 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaInit.cpp')
-rw-r--r--lib/Sema/SemaInit.cpp15
1 files changed, 11 insertions, 4 deletions
diff --git a/lib/Sema/SemaInit.cpp b/lib/Sema/SemaInit.cpp
index 98db60854f..3540cd02e6 100644
--- a/lib/Sema/SemaInit.cpp
+++ b/lib/Sema/SemaInit.cpp
@@ -2273,10 +2273,17 @@ static OverloadingResult TryRefInitWithConversionFunction(Sema &S,
Sema::ReferenceCompareResult NewRefRelationship
= S.CompareReferenceRelationship(DeclLoc, T1, T2.getNonReferenceType(),
NewDerivedToBase);
- assert(NewRefRelationship != Sema::Ref_Incompatible &&
- "Overload resolution picked a bad conversion function");
- (void)NewRefRelationship;
- if (NewDerivedToBase)
+ if (NewRefRelationship == Sema::Ref_Incompatible) {
+ // If the type we've converted to is not reference-related to the
+ // type we're looking for, then there is another conversion step
+ // we need to perform to produce a temporary of the right type
+ // that we'll be binding to.
+ ImplicitConversionSequence ICS;
+ ICS.setStandard();
+ ICS.Standard = Best->FinalConversion;
+ T2 = ICS.Standard.getToType(2);
+ Sequence.AddConversionSequenceStep(ICS, T2);
+ } else if (NewDerivedToBase)
Sequence.AddDerivedToBaseCastStep(
S.Context.getQualifiedType(T1,
T2.getNonReferenceType().getQualifiers()),