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 | cba72b1f620fd1d520da3f8e1100414c0a693cf4 (patch) | |
tree | b83c46c1e425a863762a6fc08fb6ca8097512f26 /clang/lib/Sema/SemaTemplateDeduction.cpp | |
parent | f4ca47bda828b5349e6d345f7a180248ee7547bd (diff) | |
download | bcm5719-llvm-cba72b1f620fd1d520da3f8e1100414c0a693cf4.tar.gz bcm5719-llvm-cba72b1f620fd1d520da3f8e1100414c0a693cf4.zip |
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.
llvm-svn: 123966
Diffstat (limited to 'clang/lib/Sema/SemaTemplateDeduction.cpp')
-rw-r--r-- | clang/lib/Sema/SemaTemplateDeduction.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaTemplateDeduction.cpp b/clang/lib/Sema/SemaTemplateDeduction.cpp index fc480391ea1..333eb32293a 100644 --- a/clang/lib/Sema/SemaTemplateDeduction.cpp +++ b/clang/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(); |