[cfe-commits] r131810 - in /cfe/trunk: lib/AST/ExprClassification.cpp test/SemaCXX/member-pointer.cpp

Douglas Gregor dgregor at apple.com
Sat May 21 14:04:55 PDT 2011


Author: dgregor
Date: Sat May 21 16:04:55 2011
New Revision: 131810

URL: http://llvm.org/viewvc/llvm-project?rev=131810&view=rev
Log:
Classify bound member function types are member function types. Fixes
PR9973 / <rdar://problem/9479191>.

Modified:
    cfe/trunk/lib/AST/ExprClassification.cpp
    cfe/trunk/test/SemaCXX/member-pointer.cpp

Modified: cfe/trunk/lib/AST/ExprClassification.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprClassification.cpp?rev=131810&r1=131809&r2=131810&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ExprClassification.cpp (original)
+++ cfe/trunk/lib/AST/ExprClassification.cpp Sat May 21 16:04:55 2011
@@ -465,14 +465,16 @@
   //   is a pointer to a data member is of the same value category as its first
   //   operand.
   if (E->getOpcode() == BO_PtrMemD)
-    return E->getType()->isFunctionType() ? Cl::CL_MemberFunction :
-      ClassifyInternal(Ctx, E->getLHS());
+    return (E->getType()->isFunctionType() || E->getType() == Ctx.BoundMemberTy)
+             ? Cl::CL_MemberFunction 
+             : ClassifyInternal(Ctx, E->getLHS());
 
   // C++ [expr.mptr.oper]p6: The result of an ->* expression is an lvalue if its
   //   second operand is a pointer to data member and a prvalue otherwise.
   if (E->getOpcode() == BO_PtrMemI)
-    return E->getType()->isFunctionType() ?
-      Cl::CL_MemberFunction : Cl::CL_LValue;
+    return (E->getType()->isFunctionType() || E->getType() == Ctx.BoundMemberTy)
+             ? Cl::CL_MemberFunction 
+             : Cl::CL_LValue;
 
   // All other binary operations are prvalues.
   return Cl::CL_PRValue;

Modified: cfe/trunk/test/SemaCXX/member-pointer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/member-pointer.cpp?rev=131810&r1=131809&r2=131810&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/member-pointer.cpp (original)
+++ cfe/trunk/test/SemaCXX/member-pointer.cpp Sat May 21 16:04:55 2011
@@ -271,3 +271,28 @@
 
   template void B<int>::test0b(); // expected-note {{in instantiation}}
 }
+
+namespace PR9973 {
+  template<class R, class T> struct dm
+  {
+    typedef R T::*F;
+    F f_;
+    template<class U> int & call(U u)
+    { return u->*f_; } // expected-error{{non-const lvalue reference to type 'int' cannot bind to a temporary of type '<bound member function type>'}}
+
+    template<class U> int operator()(U u)
+    { call(u); } // expected-note{{in instantiation of}}
+  };
+
+  template<class R, class T> 
+  dm<R, T> mem_fn(R T::*) ;
+
+  struct test
+  { int nullary_v(); };
+
+  void f()
+  {
+    test* t;
+    mem_fn(&test::nullary_v)(t); // expected-note{{in instantiation of}}
+  }
+}





More information about the cfe-commits mailing list