Commit 32facac8 by Martin v. Löwis Committed by Martin v. Löwis

typeck.c (get_member_function_from_ptrfunc): Allow extraction of function…

typeck.c (get_member_function_from_ptrfunc): Allow extraction of function pointer from pmfs with no object given.

	* typeck.c (get_member_function_from_ptrfunc): Allow extraction of
	function pointer from pmfs with no object given.
	(convert_for_assignment): Do not return error when converting
	pmfs.

From-SVN: r29559
parent 0fb6bbf5
1999-09-21 Martin v. Lwis <loewis@informatik.hu-berlin.de>
* typeck.c (get_member_function_from_ptrfunc): Allow extraction of
function pointer from pmfs with no object given.
(convert_for_assignment): Do not return error when converting
pmfs.
1999-09-21 Alex Samuel <samuel@codesourcery.com> 1999-09-21 Alex Samuel <samuel@codesourcery.com>
* lex.c (internal_filename): New variable. * lex.c (internal_filename): New variable.
......
...@@ -2808,6 +2808,17 @@ get_member_function_from_ptrfunc (instance_ptrptr, function) ...@@ -2808,6 +2808,17 @@ get_member_function_from_ptrfunc (instance_ptrptr, function)
tree instance_ptr = *instance_ptrptr; tree instance_ptr = *instance_ptrptr;
if (instance_ptr == error_mark_node
&& TREE_CODE (function) == PTRMEM_CST)
{
/* Extracting the function address from a pmf is only
allowed with -Wno-pmf-conversions. It only works for
pmf constants. */
e1 = build_addr_func (PTRMEM_CST_MEMBER (function));
e1 = convert (TYPE_PTRMEMFUNC_FN_TYPE (TREE_TYPE (function)), e1);
return e1;
}
if (TREE_SIDE_EFFECTS (instance_ptr)) if (TREE_SIDE_EFFECTS (instance_ptr))
instance_ptr = save_expr (instance_ptr); instance_ptr = save_expr (instance_ptr);
...@@ -6425,25 +6436,28 @@ convert_for_assignment (type, rhs, errtype, fndecl, parmnum) ...@@ -6425,25 +6436,28 @@ convert_for_assignment (type, rhs, errtype, fndecl, parmnum)
cv-unqualified type of the left operand. */ cv-unqualified type of the left operand. */
if (!can_convert_arg (type, rhstype, rhs)) if (!can_convert_arg (type, rhstype, rhs))
{ {
/* When -Wno-pmf-converions is use, we just silently allow /* When -Wno-pmf-conversions is use, we just silently allow
conversions from pointers-to-members to plain pointers. If conversions from pointers-to-members to plain pointers. If
the conversion doesn't work, cp_convert will complain. */ the conversion doesn't work, cp_convert will complain. */
if (!warn_pmf2ptr if (!warn_pmf2ptr
&& TYPE_PTR_P (type) && TYPE_PTR_P (type)
&& TYPE_PTRMEMFUNC_P (rhstype)) && TYPE_PTRMEMFUNC_P (rhstype))
rhs = cp_convert (strip_top_quals (type), rhs); rhs = cp_convert (strip_top_quals (type), rhs);
/* If the right-hand side has unknown type, then it is an else
overloaded function. Call instantiate_type to get error {
messages. */ /* If the right-hand side has unknown type, then it is an
else if (rhstype == unknown_type_node) overloaded function. Call instantiate_type to get error
instantiate_type (type, rhs, 1); messages. */
else if (fndecl) if (rhstype == unknown_type_node)
cp_error ("cannot convert `%T' to `%T' for argument `%P' to `%D'", instantiate_type (type, rhs, 1);
rhstype, type, parmnum, fndecl); else if (fndecl)
else cp_error ("cannot convert `%T' to `%T' for argument `%P' to `%D'",
cp_error ("cannot convert `%T' to `%T' in %s", rhstype, type, rhstype, type, parmnum, fndecl);
errtype); else
return error_mark_node; cp_error ("cannot convert `%T' to `%T' in %s", rhstype, type,
errtype);
return error_mark_node;
}
} }
return perform_implicit_conversion (strip_top_quals (type), rhs); return perform_implicit_conversion (strip_top_quals (type), rhs);
} }
......
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