tree.c (cp_tree_equal): Handle pointers to member functions.
authorMark Mitchell <mark@markmitchell.com>
Sun, 24 May 1998 23:57:48 +0000 (23:57 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Sun, 24 May 1998 23:57:48 +0000 (23:57 +0000)
1998-05-24  Mark Mitchell  <mark@markmitchell.com>
* tree.c (cp_tree_equal): Handle pointers to member functions.

From-SVN: r20038

gcc/cp/ChangeLog
gcc/cp/tree.c
gcc/testsuite/g++.old-deja/g++.pt/nontype4.C [new file with mode: 0644]

index 0bf7d8a12474565275ea508324148e110455ddd5..b54b78fadd5f8de61d8e812bdaa02a3f253d4583 100644 (file)
@@ -1,5 +1,7 @@
 1998-05-24  Mark Mitchell  <mark@markmitchell.com>
 
+       * tree.c (cp_tree_equal): Handle pointers to member functions.
+
        * call.c (maybe_handle_implicit_object): Handle QUAL_CONVs.  Make
        sure the type of the REF_BIND is a reference type.
        (maybe_handle_ref_bind, compare_ics): Rename reference_type to
index ce601184d23a86d23de8887e688d024be1cb67b7..a5f30eaa8515d6deb765199b074e8e4fb0c6fb85 100644 (file)
@@ -2134,7 +2134,23 @@ cp_tree_equal (t1, t2)
                  TREE_STRING_LENGTH (t1));
 
     case CONSTRUCTOR:
-      abort ();
+      /* We need to do this when determining whether or not two
+        non-type pointer to member function template arguments
+        are the same.  */
+      if (!(comptypes (TREE_TYPE (t1), TREE_TYPE (t2), 1)
+           /* The first operand is RTL.  */
+           && TREE_OPERAND (t1, 0) == TREE_OPERAND (t2, 0)))
+       return 0;
+      return cp_tree_equal (TREE_OPERAND (t1, 1), TREE_OPERAND (t2, 1));
+
+    case TREE_LIST:
+      cmp = cp_tree_equal (TREE_PURPOSE (t1), TREE_PURPOSE (t2));
+      if (cmp <= 0)
+       return cmp;
+      cmp = cp_tree_equal (TREE_VALUE (t1), TREE_VALUE (t2));
+      if (cmp <= 0)
+       return cmp;
+      return cp_tree_equal (TREE_CHAIN (t1), TREE_CHAIN (t2));
 
     case SAVE_EXPR:
       return cp_tree_equal (TREE_OPERAND (t1, 0), TREE_OPERAND (t2, 0));
diff --git a/gcc/testsuite/g++.old-deja/g++.pt/nontype4.C b/gcc/testsuite/g++.old-deja/g++.pt/nontype4.C
new file mode 100644 (file)
index 0000000..2aa38b1
--- /dev/null
@@ -0,0 +1,31 @@
+// Build don't link:
+
+template <class R, void (R::* A) (void)>
+class s
+{
+public:
+  s (R &r) : _r (r) {}
+
+  void e (void) { (_r.*A) (); }
+
+private:
+  R &_r;
+};
+
+class x
+{
+public:
+  void test1 (void) { int j = 0; }
+  void test2 (void) { int j = 1; }
+};
+
+int
+main (void)
+{
+  x r;
+
+  s<x, &x::test1> c4 (r);
+  s<x, &x::test2> c5 (r);
+
+  return 0;
+}