summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaOverload.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2009-11-13 18:44:21 +0000
committerDouglas Gregor <dgregor@apple.com>2009-11-13 18:44:21 +0000
commit379d84b7ed24980a3dbd3d60e4ab2bacce290c0c (patch)
tree7a05374f27c08e4419a4167ba3ffdd9017488c00 /clang/lib/Sema/SemaOverload.cpp
parent07eae02fc7252d4f7c13aac82be47d650b3057bf (diff)
downloadbcm5719-llvm-379d84b7ed24980a3dbd3d60e4ab2bacce290c0c.tar.gz
bcm5719-llvm-379d84b7ed24980a3dbd3d60e4ab2bacce290c0c.zip
When performing copy initialization (= "implicit conversion", here) to
a class type from itself or a derived class thereof, enumerate constructors and permit user-defined conversions to the arguments of those constructors. This fixes the wacky implicit conversion sequence used in std::auto_ptr's lame emulation of move semantics. llvm-svn: 88670
Diffstat (limited to 'clang/lib/Sema/SemaOverload.cpp')
-rw-r--r--clang/lib/Sema/SemaOverload.cpp15
1 files changed, 10 insertions, 5 deletions
diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index 3f3627d5900..3948b22f7b6 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -1399,6 +1399,13 @@ Sema::OverloadingResult Sema::IsUserDefinedConversion(
// functions are all the converting constructors (12.3.1) of
// that class. The argument list is the expression-list within
// the parentheses of the initializer.
+ bool SuppressUserConversions = !UserCast;
+ if (Context.hasSameUnqualifiedType(ToType, From->getType()) ||
+ IsDerivedFrom(From->getType(), ToType)) {
+ SuppressUserConversions = false;
+ AllowConversionFunctions = false;
+ }
+
DeclarationName ConstructorName
= Context.DeclarationNames.getCXXConstructorName(
Context.getCanonicalType(ToType).getUnqualifiedType());
@@ -1420,15 +1427,13 @@ Sema::OverloadingResult Sema::IsUserDefinedConversion(
Constructor->isConvertingConstructor(AllowExplicit)) {
if (ConstructorTmpl)
AddTemplateOverloadCandidate(ConstructorTmpl, false, 0, 0, &From,
- 1, CandidateSet,
- /*SuppressUserConversions=*/!UserCast,
- ForceRValue);
+ 1, CandidateSet,
+ SuppressUserConversions, ForceRValue);
else
// Allow one user-defined conversion when user specifies a
// From->ToType conversion via an static cast (c-style, etc).
AddOverloadCandidate(Constructor, &From, 1, CandidateSet,
- /*SuppressUserConversions=*/!UserCast,
- ForceRValue);
+ SuppressUserConversions, ForceRValue);
}
}
}
OpenPOWER on IntegriCloud