aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin v. Löwis <loewis@informatik.hu-berlin.de>1999-09-21 19:49:04 +0000
committerMartin v. Löwis <loewis@gcc.gnu.org>1999-09-21 19:49:04 +0000
commit32facac80826f8b0b5e1906a5d698f27051050cf (patch)
tree1a4ce5a327b8cf64819cd5291d11644c4c2726e1
parent0fb6bbf56e2261d41de209375829d8c2b8456f6c (diff)
downloadgcc-32facac80826f8b0b5e1906a5d698f27051050cf.zip
gcc-32facac80826f8b0b5e1906a5d698f27051050cf.tar.gz
gcc-32facac80826f8b0b5e1906a5d698f27051050cf.tar.bz2
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
-rw-r--r--gcc/cp/ChangeLog7
-rw-r--r--gcc/cp/typeck.c40
2 files changed, 34 insertions, 13 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 2fc11ec..fecaede 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,10 @@
+1999-09-21 Martin v. Löwis <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>
* lex.c (internal_filename): New variable.
diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index f4cdc92..a4d0255 100644
--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -2808,6 +2808,17 @@ get_member_function_from_ptrfunc (instance_ptrptr, function)
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))
instance_ptr = save_expr (instance_ptr);
@@ -6425,25 +6436,28 @@ convert_for_assignment (type, rhs, errtype, fndecl, parmnum)
cv-unqualified type of the left operand. */
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
the conversion doesn't work, cp_convert will complain. */
if (!warn_pmf2ptr
&& TYPE_PTR_P (type)
&& TYPE_PTRMEMFUNC_P (rhstype))
rhs = cp_convert (strip_top_quals (type), rhs);
- /* If the right-hand side has unknown type, then it is an
- overloaded function. Call instantiate_type to get error
- messages. */
- else if (rhstype == unknown_type_node)
- instantiate_type (type, rhs, 1);
- else if (fndecl)
- cp_error ("cannot convert `%T' to `%T' for argument `%P' to `%D'",
- rhstype, type, parmnum, fndecl);
- else
- cp_error ("cannot convert `%T' to `%T' in %s", rhstype, type,
- errtype);
- return error_mark_node;
+ else
+ {
+ /* If the right-hand side has unknown type, then it is an
+ overloaded function. Call instantiate_type to get error
+ messages. */
+ if (rhstype == unknown_type_node)
+ instantiate_type (type, rhs, 1);
+ else if (fndecl)
+ cp_error ("cannot convert `%T' to `%T' for argument `%P' to `%D'",
+ rhstype, type, parmnum, fndecl);
+ else
+ 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);
}