OSDN Git Service

* typeck.c (build_ptrmemfunc): Save the input pmf.
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 24 Aug 2000 01:57:19 +0000 (01:57 +0000)
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 24 Aug 2000 01:57:19 +0000 (01:57 +0000)
        * method.c (process_modifiers): Use same_type_p.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@35930 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cp/ChangeLog
gcc/cp/method.c
gcc/cp/typeck.c
gcc/testsuite/g++.old-deja/g++.other/pmf5.C [new file with mode: 0644]

index ae35173..c78ff70 100644 (file)
@@ -1,3 +1,9 @@
+2000-08-23  Jason Merrill  <jason@redhat.com>
+
+       * typeck.c (build_ptrmemfunc): Save the input pmf.
+
+       * method.c (process_modifiers): Use same_type_p.
+
 2000-08-23  Mark Mitchell  <mark@codesourcery.com>
 
        * cp-tree.h (DECL_CLONED_FUNCTION_P): Check DECL_LANG_SPECIFIC.
index 0926021..4c024d1 100644 (file)
@@ -1253,8 +1253,8 @@ process_modifiers (parmtype)
   if (TYPE_READONLY (parmtype))
     OB_PUTC ('C');
   if (TREE_CODE (parmtype) == INTEGER_TYPE
-      && parmtype != char_type_node
-      && parmtype != wchar_type_node
+      && ! same_type_p (parmtype, char_type_node)
+      && ! same_type_p (parmtype, wchar_type_node)
       && (TYPE_MAIN_VARIANT (parmtype)
          == unsigned_type (TYPE_MAIN_VARIANT (parmtype)))
       && ! TYPE_FOR_JAVA (parmtype))
index 9ab9b87..3b3313d 100644 (file)
@@ -6132,6 +6132,9 @@ build_ptrmemfunc (type, pfn, force)
       if (TREE_CODE (pfn) != PTRMEM_CST && same_type_p (to_type, pfn_type))
        return pfn;
 
+      if (TREE_SIDE_EFFECTS (pfn))
+       pfn = save_expr (pfn);
+
       if (flag_new_abi)
        {
          /* Under the new ABI, the conversion is easy.  Just adjust
diff --git a/gcc/testsuite/g++.old-deja/g++.other/pmf5.C b/gcc/testsuite/g++.old-deja/g++.other/pmf5.C
new file mode 100644 (file)
index 0000000..e3e6a9f
--- /dev/null
@@ -0,0 +1,38 @@
+// Bug: g++ expanded b->member() multiple times, causing the optimizer to
+// decide that things weren't related and optimize 'die' into an infinite
+// loop.
+
+struct A {
+  virtual ~A() { }
+  void f (bool) { }
+};
+
+typedef void (A::*pmf_void)();
+typedef void (A::*pmf_bool)(bool);
+
+struct B {
+  ~B() {}
+  pmf_void member() const { return mbr; }
+  pmf_void mbr;
+};
+
+A *a;
+B *b;
+
+void die (bool param) {
+  pmf_bool pmf = (pmf_bool)(b->member());
+  (a->*pmf)(param);
+}
+
+int main ()
+{
+  A a2;
+  B b2;
+
+  b2.mbr = reinterpret_cast<pmf_void>(&A::f);
+
+  a = &a2;
+  b = &b2;
+
+  die (true);
+}