diff options
author | Douglas Gregor <dgregor@apple.com> | 2011-01-21 05:18:22 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2011-01-21 05:18:22 +0000 |
commit | 2ad746aeb90e86cea7afaf552a02ae3f3b5ec859 (patch) | |
tree | e5e80a65e5c0b46847fd11fa81c8028377f2fe6c /lib/Sema/SemaTemplateDeduction.cpp | |
parent | c80e8115278ba1537c8b517a083ecbd0a018b579 (diff) |
Implement the special template argument deduction rule for T&& in a
call (C++0x [temp.deduct.call]p3).
As part of this, start improving the reference-binding implementation
used in the computation of implicit conversion sequences (for overload
resolution) to reflect C++0x semantics. It still needs more work and
testing, of course.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@123966 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaTemplateDeduction.cpp')
-rw-r--r-- | lib/Sema/SemaTemplateDeduction.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/Sema/SemaTemplateDeduction.cpp b/lib/Sema/SemaTemplateDeduction.cpp index fc480391ea..333eb32293 100644 --- a/lib/Sema/SemaTemplateDeduction.cpp +++ b/lib/Sema/SemaTemplateDeduction.cpp @@ -2399,6 +2399,18 @@ static bool AdjustFunctionParmAndArgTypesForDeduction(Sema &S, ParamType = ParamType.getLocalUnqualifiedType(); const ReferenceType *ParamRefType = ParamType->getAs<ReferenceType>(); if (ParamRefType) { + // [C++0x] If P is an rvalue reference to a cv-unqualified + // template parameter and the argument is an lvalue, the type + // "lvalue reference to A" is used in place of A for type + // deduction. + if (const RValueReferenceType *RValueRef + = dyn_cast<RValueReferenceType>(ParamType)) { + if (!RValueRef->getPointeeType().getQualifiers() && + isa<TemplateTypeParmType>(RValueRef->getPointeeType()) && + Arg->Classify(S.Context).isLValue()) + ArgType = S.Context.getLValueReferenceType(ArgType); + } + // [...] If P is a reference type, the type referred to by P is used // for type deduction. ParamType = ParamRefType->getPointeeType(); |