diff options
author | Ollie Wild <aaw@google.com> | 2007-11-24 08:37:00 +0000 |
---|---|---|
committer | Ollie Wild <aaw@gcc.gnu.org> | 2007-11-24 08:37:00 +0000 |
commit | a298680ca5bbf7254b79e310e683c33baffa18af (patch) | |
tree | d83e3f3a97b8de7bd50a0d41aa0d0b08d0d85534 /gcc | |
parent | af90c10fe1738861ec3b9be24a13e8215905c6e2 (diff) | |
download | gcc-a298680ca5bbf7254b79e310e683c33baffa18af.zip gcc-a298680ca5bbf7254b79e310e683c33baffa18af.tar.gz gcc-a298680ca5bbf7254b79e310e683c33baffa18af.tar.bz2 |
typeck.c (delta_from_ptrmemfunc): New function.
gcc/cp/
* typeck.c (delta_from_ptrmemfunc): New function.
(get_member_function_from_ptrfunc): Call delta_from_ptrmemfunc.
(build_binary_op): Call delta_from_ptrmemfunc.
From-SVN: r130394
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/typeck.c | 31 |
2 files changed, 30 insertions, 7 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 9038270..d07b5a0 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2007-11-24 Ollie Wild <aaw@google.com> + + * typeck.c (delta_from_ptrmemfunc): New function. + (get_member_function_from_ptrfunc): Call delta_from_ptrmemfunc. + (build_binary_op): Call delta_from_ptrmemfunc. + 2007-11-23 Jakub Jelinek <jakub@redhat.com> PR c++/30293 diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index d167de2..da46bb3 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -46,6 +46,7 @@ along with GCC; see the file COPYING3. If not see #include "params.h" static tree pfn_from_ptrmemfunc (tree); +static tree delta_from_ptrmemfunc (tree); static tree convert_for_assignment (tree, tree, const char *, tree, int); static tree cp_pointer_int_sum (enum tree_code, tree, tree); static tree rationalize_conditional_expr (enum tree_code, tree); @@ -2586,7 +2587,7 @@ get_member_function_from_ptrfunc (tree *instance_ptrptr, tree function) /* Start by extracting all the information from the PMF itself. */ e3 = pfn_from_ptrmemfunc (function); - delta = build_ptrmemfunc_access_expr (function, delta_identifier); + delta = delta_from_ptrmemfunc (function); idx = build1 (NOP_EXPR, vtable_index_type, e3); switch (TARGET_PTRMEMFUNC_VBIT_LOCATION) { @@ -3370,8 +3371,7 @@ build_binary_op (enum tree_code code, tree orig_op0, tree orig_op1, == ptrmemfunc_vbit_in_delta) { tree pfn0 = pfn_from_ptrmemfunc (op0); - tree delta0 = build_ptrmemfunc_access_expr (op0, - delta_identifier); + tree delta0 = delta_from_ptrmemfunc (op0); tree e1 = cp_build_binary_op (EQ_EXPR, pfn0, fold_convert (TREE_TYPE (pfn0), @@ -3412,10 +3412,8 @@ build_binary_op (enum tree_code code, tree orig_op0, tree orig_op1, pfn0 = pfn_from_ptrmemfunc (op0); pfn1 = pfn_from_ptrmemfunc (op1); - delta0 = build_ptrmemfunc_access_expr (op0, - delta_identifier); - delta1 = build_ptrmemfunc_access_expr (op1, - delta_identifier); + delta0 = delta_from_ptrmemfunc (op0); + delta1 = delta_from_ptrmemfunc (op1); if (TARGET_PTRMEMFUNC_VBIT_LOCATION == ptrmemfunc_vbit_in_delta) { @@ -6290,6 +6288,25 @@ pfn_from_ptrmemfunc (tree t) return build_ptrmemfunc_access_expr (t, pfn_identifier); } +/* Return an expression for DELTA from the pointer-to-member function + given by T. */ + +static tree +delta_from_ptrmemfunc (tree t) +{ + if (TREE_CODE (t) == PTRMEM_CST) + { + tree delta; + tree pfn; + + expand_ptrmemfunc_cst (t, &delta, &pfn); + if (delta) + return delta; + } + + return build_ptrmemfunc_access_expr (t, delta_identifier); +} + /* Convert value RHS to type TYPE as preparation for an assignment to an lvalue of type TYPE. ERRTYPE is a string to use in error messages: "assignment", "return", etc. If FNDECL is non-NULL, we |