Commit a298680c by Ollie Wild Committed by Ollie Wild

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
parent af90c10f
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> 2007-11-23 Jakub Jelinek <jakub@redhat.com>
PR c++/30293 PR c++/30293
......
...@@ -46,6 +46,7 @@ along with GCC; see the file COPYING3. If not see ...@@ -46,6 +46,7 @@ along with GCC; see the file COPYING3. If not see
#include "params.h" #include "params.h"
static tree pfn_from_ptrmemfunc (tree); 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 convert_for_assignment (tree, tree, const char *, tree, int);
static tree cp_pointer_int_sum (enum tree_code, tree, tree); static tree cp_pointer_int_sum (enum tree_code, tree, tree);
static tree rationalize_conditional_expr (enum tree_code, tree); static tree rationalize_conditional_expr (enum tree_code, tree);
...@@ -2586,7 +2587,7 @@ get_member_function_from_ptrfunc (tree *instance_ptrptr, tree function) ...@@ -2586,7 +2587,7 @@ get_member_function_from_ptrfunc (tree *instance_ptrptr, tree function)
/* Start by extracting all the information from the PMF itself. */ /* Start by extracting all the information from the PMF itself. */
e3 = pfn_from_ptrmemfunc (function); 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); idx = build1 (NOP_EXPR, vtable_index_type, e3);
switch (TARGET_PTRMEMFUNC_VBIT_LOCATION) switch (TARGET_PTRMEMFUNC_VBIT_LOCATION)
{ {
...@@ -3370,8 +3371,7 @@ build_binary_op (enum tree_code code, tree orig_op0, tree orig_op1, ...@@ -3370,8 +3371,7 @@ build_binary_op (enum tree_code code, tree orig_op0, tree orig_op1,
== ptrmemfunc_vbit_in_delta) == ptrmemfunc_vbit_in_delta)
{ {
tree pfn0 = pfn_from_ptrmemfunc (op0); tree pfn0 = pfn_from_ptrmemfunc (op0);
tree delta0 = build_ptrmemfunc_access_expr (op0, tree delta0 = delta_from_ptrmemfunc (op0);
delta_identifier);
tree e1 = cp_build_binary_op (EQ_EXPR, tree e1 = cp_build_binary_op (EQ_EXPR,
pfn0, pfn0,
fold_convert (TREE_TYPE (pfn0), fold_convert (TREE_TYPE (pfn0),
...@@ -3412,10 +3412,8 @@ build_binary_op (enum tree_code code, tree orig_op0, tree orig_op1, ...@@ -3412,10 +3412,8 @@ build_binary_op (enum tree_code code, tree orig_op0, tree orig_op1,
pfn0 = pfn_from_ptrmemfunc (op0); pfn0 = pfn_from_ptrmemfunc (op0);
pfn1 = pfn_from_ptrmemfunc (op1); pfn1 = pfn_from_ptrmemfunc (op1);
delta0 = build_ptrmemfunc_access_expr (op0, delta0 = delta_from_ptrmemfunc (op0);
delta_identifier); delta1 = delta_from_ptrmemfunc (op1);
delta1 = build_ptrmemfunc_access_expr (op1,
delta_identifier);
if (TARGET_PTRMEMFUNC_VBIT_LOCATION if (TARGET_PTRMEMFUNC_VBIT_LOCATION
== ptrmemfunc_vbit_in_delta) == ptrmemfunc_vbit_in_delta)
{ {
...@@ -6290,6 +6288,25 @@ pfn_from_ptrmemfunc (tree t) ...@@ -6290,6 +6288,25 @@ pfn_from_ptrmemfunc (tree t)
return build_ptrmemfunc_access_expr (t, pfn_identifier); 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 /* 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 an lvalue of type TYPE. ERRTYPE is a string to use in error
messages: "assignment", "return", etc. If FNDECL is non-NULL, we messages: "assignment", "return", etc. If FNDECL is non-NULL, we
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment