summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2009-02-02 22:11:10 +0000
committerDouglas Gregor <dgregor@apple.com>2009-02-02 22:11:10 +0000
commitbb2e688396e63030fbf57bd92f54875025763fe0 (patch)
treeb8031be364c62448c248780c1aac35c6e8f33f9d /clang/lib
parentd931a87f902a045aa82797228ad5a0963da2c6f4 (diff)
downloadbcm5719-llvm-bb2e688396e63030fbf57bd92f54875025763fe0.tar.gz
bcm5719-llvm-bb2e688396e63030fbf57bd92f54875025763fe0.zip
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. llvm-svn: 63554
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Sema/SemaOverload.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index 1fa703c775a..7219f19a97c 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/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;
}
}
OpenPOWER on IntegriCloud