diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2012-02-11 19:22:50 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2012-02-11 19:22:50 +0000 |
commit | f2e4dfcd325db2c1a960697be2c750f277dcafce (patch) | |
tree | 5b2997b51f374caa7d242f200db5200b17f86fdf /lib/Sema/SemaInit.cpp | |
parent | 8327118ff60cd9c4812fba1e5ba4eb3cb5ed3401 (diff) |
Implement core issue 5: a temporary created for copy-initialization has a
cv-unqualified type. This is essential in order to allow move-only objects of
const-qualified types to be copy-initialized via a converting constructor.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150309 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaInit.cpp')
-rw-r--r-- | lib/Sema/SemaInit.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/Sema/SemaInit.cpp b/lib/Sema/SemaInit.cpp index 6fff123b7a..32d1ec1c22 100644 --- a/lib/Sema/SemaInit.cpp +++ b/lib/Sema/SemaInit.cpp @@ -3743,8 +3743,10 @@ static void TryUserDefinedConversion(Sema &S, if (isa<CXXConstructorDecl>(Function)) { // Add the user-defined conversion step. Any cv-qualification conversion is - // subsumed by the initialization. - Sequence.AddUserConversionStep(Function, Best->FoundDecl, DestType, + // subsumed by the initialization. Per DR5, the created temporary is of the + // cv-unqualified type of the destination. + Sequence.AddUserConversionStep(Function, Best->FoundDecl, + DestType.getUnqualifiedType(), HadMultipleCandidates); return; } @@ -3752,7 +3754,7 @@ static void TryUserDefinedConversion(Sema &S, // Add the user-defined conversion step that calls the conversion function. QualType ConvType = Function->getCallResultType(); if (ConvType->getAs<RecordType>()) { - // If we're converting to a class type, there may be an copy if + // If we're converting to a class type, there may be an copy of // the resulting temporary object (possible to create an object of // a base class type). That copy is not a separate conversion, so // we just make a note of the actual destination type (possibly a @@ -4899,7 +4901,7 @@ InitializationSequence::Perform(Sema &S, Loc, ConstructorArgs)) return ExprError(); - // Build the an expression that constructs a temporary. + // Build an expression that constructs a temporary. CurInit = S.BuildCXXConstructExpr(Loc, Step->Type, Constructor, move_arg(ConstructorArgs), HadMultipleCandidates, |