aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2000-08-23 21:57:19 -0400
committerJason Merrill <jason@gcc.gnu.org>2000-08-23 21:57:19 -0400
commit7def1251301aac2e419c8a1d84d73d08d32debeb (patch)
treee56284271522f5cf16f3706d3c21d3c5c67d2425
parent5f1c312aa06c452609c7fab1cf390dde6dfb8722 (diff)
downloadgcc-7def1251301aac2e419c8a1d84d73d08d32debeb.zip
gcc-7def1251301aac2e419c8a1d84d73d08d32debeb.tar.gz
gcc-7def1251301aac2e419c8a1d84d73d08d32debeb.tar.bz2
typeck.c (build_ptrmemfunc): Save the input pmf.
* typeck.c (build_ptrmemfunc): Save the input pmf. * method.c (process_modifiers): Use same_type_p. From-SVN: r35930
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/method.c4
-rw-r--r--gcc/cp/typeck.c3
-rw-r--r--gcc/testsuite/g++.old-deja/g++.other/pmf5.C38
4 files changed, 49 insertions, 2 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index ae35173..c78ff70 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -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.
diff --git a/gcc/cp/method.c b/gcc/cp/method.c
index 0926021..4c024d1 100644
--- a/gcc/cp/method.c
+++ b/gcc/cp/method.c
@@ -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))
diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index 9ab9b87..3b3313d 100644
--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -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
index 0000000..e3e6a9f
--- /dev/null
+++ b/gcc/testsuite/g++.old-deja/g++.other/pmf5.C
@@ -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);
+}