diff options
author | Douglas Gregor <dgregor@apple.com> | 2009-02-02 22:11:10 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2009-02-02 22:11:10 +0000 |
commit | 2b1e0039a1937e3df59b5c99bcf4746360db3441 (patch) | |
tree | 4e15ad97d945346442306a1409aa39fffaaac919 /lib/Sema/SemaOverload.cpp | |
parent | 88b5396b0897f28d22ae3debf4a0d97b33b6c362 (diff) |
Steve set me straight on this one. GCC was right, EDG was wrong: the
direct-initialization following a user-defined conversion can select
any constructor; it just can't employ any user-defined
conversions. So we ban those conversions and classify the constructor
call based on the relationship between the "from" and "to" types in
the conversion.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63554 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaOverload.cpp')
-rw-r--r-- | lib/Sema/SemaOverload.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/Sema/SemaOverload.cpp b/lib/Sema/SemaOverload.cpp index 1fa703c775..7219f19a97 100644 --- a/lib/Sema/SemaOverload.cpp +++ b/lib/Sema/SemaOverload.cpp @@ -383,7 +383,10 @@ Sema::TryImplicitConversion(Expr* From, QualType ToType, // called for those cases. if (CXXConstructorDecl *Constructor = dyn_cast<CXXConstructorDecl>(ICS.UserDefined.ConversionFunction)) { - if (Constructor->isCopyConstructor(Context)) { + QualType FromCanon + = Context.getCanonicalType(From->getType().getUnqualifiedType()); + QualType ToCanon = Context.getCanonicalType(ToType).getUnqualifiedType(); + if (FromCanon == ToCanon || IsDerivedFrom(FromCanon, ToCanon)) { // Turn this into a "standard" conversion sequence, so that it // gets ranked with standard conversion sequences. ICS.ConversionKind = ImplicitConversionSequence::StandardConversion; @@ -391,8 +394,7 @@ Sema::TryImplicitConversion(Expr* From, QualType ToType, ICS.Standard.FromTypePtr = From->getType().getAsOpaquePtr(); ICS.Standard.ToTypePtr = ToType.getAsOpaquePtr(); ICS.Standard.CopyConstructor = Constructor; - if (IsDerivedFrom(From->getType().getUnqualifiedType(), - ToType.getUnqualifiedType())) + if (ToCanon != FromCanon) ICS.Standard.Second = ICK_Derived_To_Base; } } |