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
This commit is contained in:
Jason Merrill 2000-08-23 21:57:19 -04:00 committed by Jason Merrill
parent 5f1c312aa0
commit 7def125130
4 changed files with 49 additions and 2 deletions

View 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.

View 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))

View 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

View File

@ -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);
}