From 24272dc03779501835117ee8782f4888b4d6a3d4 Mon Sep 17 00:00:00 2001 From: Mark Mitchell Date: Mon, 16 Apr 2001 05:51:38 +0000 Subject: cp-tree.h (TYPE_PTRMEM_CLASS_TYPE): Improve documentation. * cp-tree.h (TYPE_PTRMEM_CLASS_TYPE): Improve documentation. * mangle.c (write_pointer_to_member_type): Fix mangling of pointers to cv-qualified member function types. From-SVN: r41373 --- gcc/cp/ChangeLog | 4 ++++ gcc/cp/cp-tree.h | 6 +++++- gcc/cp/mangle.c | 19 ++++++++++++++++++- gcc/testsuite/g++.old-deja/g++.abi/mangle1.C | 7 +++++++ 4 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/g++.old-deja/g++.abi/mangle1.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 2487d9e..7809c0a 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 2001-04-15 Mark Mitchell + * cp-tree.h (TYPE_PTRMEM_CLASS_TYPE): Improve documentation. + * mangle.c (write_pointer_to_member_type): Fix mangling of + pointers to cv-qualified member function types. + * init.c (build_delete): Create a SAVE_EXPR for the address if we're going to use it more than once. diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index de82fa6..a30623a 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -2691,7 +2691,11 @@ extern int flag_new_for_scope; /* Returns the pfn field from a TYPE_PTRMEMFUNC_P. */ #define PFN_FROM_PTRMEMFUNC(NODE) pfn_from_ptrmemfunc ((NODE)) -/* For a pointer-to-member type of the form `T X::*', this is `X'. */ +/* For a pointer-to-member type of the form `T X::*', this is `X'. + For a type like `void (X::*)() const', this type is `X', not `const + X'. To get at the `const X' you have to look at the + TYPE_PTRMEM_POINTED_TO_TYPE; there, the first parameter will have + type `const X*'. */ #define TYPE_PTRMEM_CLASS_TYPE(NODE) \ (TYPE_PTRMEM_P ((NODE)) \ ? TYPE_OFFSET_BASETYPE (TREE_TYPE ((NODE))) \ diff --git a/gcc/cp/mangle.c b/gcc/cp/mangle.c index e2641a7..18f99a10 100644 --- a/gcc/cp/mangle.c +++ b/gcc/cp/mangle.c @@ -1928,7 +1928,24 @@ write_pointer_to_member_type (type) tree type; { write_char ('M'); - write_type (TYPE_PTRMEM_CLASS_TYPE (type)); + /* For a pointer-to-function member, the class type may be + cv-qualified, bug that won't be reflected in + TYPE_PTRMEM_CLASS_TYPE. So, we go fishing around in + TYPE_PTRMEM_POINTED_TO_TYPE instead. */ + if (TYPE_PTRMEMFUNC_P (type)) + { + tree fn_type; + tree this_type; + + fn_type = TYPE_PTRMEM_POINTED_TO_TYPE (type); + /* The first parameter must be a POINTER_TYPE pointing to the + `this' parameter. */ + this_type = TREE_TYPE (TREE_VALUE (TYPE_ARG_TYPES (fn_type))); + write_type (this_type); + } + /* For a pointer-to-data member, things are simpler. */ + else + write_type (TYPE_PTRMEM_CLASS_TYPE (type)); write_type (TYPE_PTRMEM_POINTED_TO_TYPE (type)); } diff --git a/gcc/testsuite/g++.old-deja/g++.abi/mangle1.C b/gcc/testsuite/g++.old-deja/g++.abi/mangle1.C new file mode 100644 index 0000000..70f0cce --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.abi/mangle1.C @@ -0,0 +1,7 @@ +// Build don't link: +// Origin: Mark Mitchell + +struct S {}; + +void f (void (S::*)()) {} +void f (void (S::*)() const) {} -- cgit v1.1