typeck.c (build_unary_op): Handle taking the address of a unique bound non-static...
authorJason Merrill <jason@yorick.cygnus.com>
Wed, 14 Apr 1999 12:16:39 +0000 (12:16 +0000)
committerJason Merrill <jason@gcc.gnu.org>
Wed, 14 Apr 1999 12:16:39 +0000 (08:16 -0400)
* typeck.c (build_unary_op): Handle taking the address of a unique
bound non-static member function.

From-SVN: r26451

gcc/cp/ChangeLog
gcc/cp/typeck.c

index 2f00fdd980388b879f2ec86e72dcfe33dcbeb80a..4e867bc065a0efa5e2f76f755263ce38bf17345b 100644 (file)
@@ -1,3 +1,8 @@
+1999-04-14  Jason Merrill  <jason@yorick.cygnus.com>
+
+       * typeck.c (build_unary_op): Handle taking the address of a unique
+       bound non-static member function.
+
 1999-04-13  Martin von Loewis  <loewis@informatik.hu-berlin.de>
 
        * lang-options.h (-Wdeprecated): New flag.
index c210410102a0c6a136b5d6f750c63b44cb86099a..fd21ed03f481d9f48163f0df4212b4951f3b60e2 100644 (file)
@@ -4685,6 +4685,28 @@ build_unary_op (code, xarg, noconvert)
          return build1 (ADDR_EXPR, unknown_type_node, arg);
        }
 
+      if (TREE_CODE (arg) == COMPONENT_REF && type_unknown_p (arg)
+         && OVL_NEXT (TREE_OPERAND (arg, 1)) == NULL_TREE)
+       {
+         /* They're trying to take the address of a unique non-static
+            member function.  This is ill-formed, but let's try to DTRT.  */
+         tree base, name;
+
+         if (current_class_type
+             && TREE_OPERAND (arg, 0) == current_class_ref)
+           /* An expression like &memfn.  */
+           pedwarn ("taking the address of a non-static member function");
+         else
+           pedwarn ("taking the address of a bound member function");
+
+         base = TREE_TYPE (TREE_OPERAND (arg, 0));
+         name = DECL_NAME (OVL_CURRENT (TREE_OPERAND (arg, 1)));
+
+         cp_pedwarn ("  to form a pointer to member function, say `&%T::%D'",
+                     base, name);
+         arg = build_offset_ref (base, name);
+       }
+
       if (type_unknown_p (arg))
        return build1 (ADDR_EXPR, unknown_type_node, arg);