[cfe-commits] r164267 - in /cfe/trunk: lib/Sema/SemaTemplateDeduction.cpp test/CXX/temp/temp.decls/temp.fct/temp.func.order/p3-0x.cpp
Eli Friedman
eli.friedman at gmail.com
Wed Sep 19 16:52:14 PDT 2012
Author: efriedma
Date: Wed Sep 19 18:52:13 2012
New Revision: 164267
URL: http://llvm.org/viewvc/llvm-project?rev=164267&view=rev
Log:
Fix a small FIXME involving template partial ordering and
member function templates with an rvalue ref qualifier.
Modified:
cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
cfe/trunk/test/CXX/temp/temp.decls/temp.fct/temp.func.order/p3-0x.cpp
Modified: cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp?rev=164267&r1=164266&r2=164267&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp Wed Sep 19 18:52:13 2012
@@ -3651,26 +3651,23 @@
llvm::SmallBitVector &Deduced);
/// \brief If this is a non-static member function,
-static void MaybeAddImplicitObjectParameterType(ASTContext &Context,
+static void AddImplicitObjectParameterType(ASTContext &Context,
CXXMethodDecl *Method,
SmallVectorImpl<QualType> &ArgTypes) {
- if (Method->isStatic())
- return;
-
- // C++ [over.match.funcs]p4:
- //
- // For non-static member functions, the type of the implicit
- // object parameter is
- // - "lvalue reference to cv X" for functions declared without a
- // ref-qualifier or with the & ref-qualifier
- // - "rvalue reference to cv X" for functions declared with the
- // && ref-qualifier
+ // C++11 [temp.func.order]p3:
+ // [...] The new parameter is of type "reference to cv A," where cv are
+ // the cv-qualifiers of the function template (if any) and A is
+ // the class of which the function template is a member.
//
- // FIXME: We don't have ref-qualifiers yet, so we don't do that part.
+ // The standard doesn't say explicitly, but we pick the appropriate kind of
+ // reference type based on [over.match.funcs]p4.
QualType ArgTy = Context.getTypeDeclType(Method->getParent());
ArgTy = Context.getQualifiedType(ArgTy,
Qualifiers::fromCVRMask(Method->getTypeQualifiers()));
- ArgTy = Context.getLValueReferenceType(ArgTy);
+ if (Method->getRefQualifier() == RQ_RValue)
+ ArgTy = Context.getRValueReferenceType(ArgTy);
+ else
+ ArgTy = Context.getLValueReferenceType(ArgTy);
ArgTypes.push_back(ArgTy);
}
@@ -3730,14 +3727,14 @@
SmallVector<QualType, 4> Args1;
unsigned Skip1 = !S.getLangOpts().CPlusPlus0x && IsNonStatic2 && !Method1;
if (S.getLangOpts().CPlusPlus0x && IsNonStatic1 && !Method2)
- MaybeAddImplicitObjectParameterType(S.Context, Method1, Args1);
+ AddImplicitObjectParameterType(S.Context, Method1, Args1);
Args1.insert(Args1.end(),
Proto1->arg_type_begin() + Skip1, Proto1->arg_type_end());
SmallVector<QualType, 4> Args2;
Skip2 = !S.getLangOpts().CPlusPlus0x && IsNonStatic1 && !Method2;
if (S.getLangOpts().CPlusPlus0x && IsNonStatic2 && !Method1)
- MaybeAddImplicitObjectParameterType(S.Context, Method2, Args2);
+ AddImplicitObjectParameterType(S.Context, Method2, Args2);
Args2.insert(Args2.end(),
Proto2->arg_type_begin() + Skip2, Proto2->arg_type_end());
Modified: cfe/trunk/test/CXX/temp/temp.decls/temp.fct/temp.func.order/p3-0x.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/temp/temp.decls/temp.fct/temp.func.order/p3-0x.cpp?rev=164267&r1=164266&r2=164267&view=diff
==============================================================================
--- cfe/trunk/test/CXX/temp/temp.decls/temp.fct/temp.func.order/p3-0x.cpp (original)
+++ cfe/trunk/test/CXX/temp/temp.decls/temp.fct/temp.func.order/p3-0x.cpp Wed Sep 19 18:52:13 2012
@@ -16,6 +16,21 @@
}
}
+namespace OperatorWithRefQualifier {
+ struct A { };
+ template<class T> struct B {
+ template<class R> int &operator*(R&) &&;
+ };
+
+ template<class T, class R> float &operator*(T&&, R&);
+ void test() {
+ A a;
+ B<A> b;
+ float &ir = b * a;
+ int &ir2 = B<A>() * a;
+ }
+}
+
namespace OrderWithStaticMember {
struct A {
template<class T> int g(T**, int=0) { return 0; }
More information about the cfe-commits
mailing list