In cp/ChangeLog:

* tree.c (cp_build_qualified_type_real): When copying
	pointer-to-method types, unshare the record that holds
	the cached pointer-to-member-function type.
In testsuite/ChangeLog:
	* g++.dg/other/ptrmem4.C: New testcase.

From-SVN: r55725
This commit is contained in:
Geoffrey Keating 2002-07-24 23:01:07 +00:00 committed by Geoffrey Keating
parent eb5da24bed
commit 3cfab7ec18
4 changed files with 32 additions and 4 deletions

View File

@ -1,3 +1,9 @@
2002-07-24 Geoffrey Keating <geoffk@redhat.com>
* tree.c (cp_build_qualified_type_real): When copying
pointer-to-method types, unshare the record that holds
the cached pointer-to-member-function type.
2002-07-23 Neil Booth <neil@daikokuya.co.uk> 2002-07-23 Neil Booth <neil@daikokuya.co.uk>
* cp-tree.h (FILE_FUNCTION_PREFIX_LEN): Remove. * cp-tree.h (FILE_FUNCTION_PREFIX_LEN): Remove.

View File

@ -644,13 +644,13 @@ cp_build_qualified_type_real (type, type_quals, complain)
result = build_qualified_type (type, type_quals); result = build_qualified_type (type, type_quals);
/* If this was a pointer-to-method type, and we just made a copy, /* If this was a pointer-to-method type, and we just made a copy,
then we need to clear the cached associated then we need to unshare the record that holds the cached
pointer-to-member-function type; it is not valid for the new pointer-to-member-function type, because these will be distinct
type. */ between the unqualified and qualified types. */
if (result != type if (result != type
&& TREE_CODE (type) == POINTER_TYPE && TREE_CODE (type) == POINTER_TYPE
&& TREE_CODE (TREE_TYPE (type)) == METHOD_TYPE) && TREE_CODE (TREE_TYPE (type)) == METHOD_TYPE)
TYPE_SET_PTRMEMFUNC_TYPE (result, NULL_TREE); TYPE_LANG_SPECIFIC (result) = NULL;
return result; return result;
} }

View File

@ -1,3 +1,7 @@
2002-07-24 Geoffrey Keating <geoffk@redhat.com>
* g++.dg/other/ptrmem4.C: New testcase.
2002-07-24 Richard Henderson <rth@redhat.com> 2002-07-24 Richard Henderson <rth@redhat.com>
* gcc.c-torture/execute/loop-2e.c: Rewrite for 64 bit and no mmap. * gcc.c-torture/execute/loop-2e.c: Rewrite for 64 bit and no mmap.

View File

@ -0,0 +1,18 @@
// Bug: This checks that the pointer-to-member-function type is not
// shared between differently-qualified pointer-to-method types.
// { dg-do compile }
struct A
{
void f () {}
};
void (A::*const cp)() = &A::f;
int main ()
{
void (A::* p)();
void (A::** ip)() = &p;
*ip = &A::f;
}