diff options
author | Mark Mitchell <mark@codesourcery.com> | 2003-07-04 05:05:19 +0000 |
---|---|---|
committer | Mark Mitchell <mmitchel@gcc.gnu.org> | 2003-07-04 05:05:19 +0000 |
commit | d6b4ea8592e338addbd24be14708f66eaa4ac63e (patch) | |
tree | 613039e905b0fbc1fe50e07889b99fdc172e8d14 /gcc/cp/cvt.c | |
parent | 5f1989e65d23624efdbf26bde56f375e3caa6a22 (diff) | |
download | gcc-d6b4ea8592e338addbd24be14708f66eaa4ac63e.tar.gz |
call.c (build_addr_func): Handle bound pointers-to-members.
* call.c (build_addr_func): Handle bound pointers-to-members.
(build_method_call): Do not call resolve_offset_ref.
(implicit_conversion): Likewise.
(resolve_scoped_fn_name): Use finish_non_static_data_member, not
resolve_offset_ref.
(resolve_args): Do not call resolve_offset_ref.
(build_conditional_expr): Likewise.
(build_new_method_call): Likewise.
* cp-tree.def (OFFSET_REF): Update documentation.
(cp_convert_to_pointer): Update handling of conversions from
pointers to members to pointers.
(ocp_convert): Do not call resolve_offset_ref.
(convert_to_void): Likewise.
(build_expr_type_conversion): Likewise.
(delete_sanity): Likewise.
(resolve_offset_ref): Simplify greatly.
(build_vec_delete): Do not call resolve_offset_ref.
* parser.c (cp_parser_postfix_expression): Call resolve_offset_ref
if appropriate.
(cp_parser_unary_expression): Use
cp_parser_simple_cast_expression.
(cp_parser_delete_expression): Likewise.
(cp_parser_cast_expression): Likewise.
(cp_parser_pm_expression): Use cp_parser_binary_op.
(cp_parser_simple_cast_expression): New function.
* rtti.c (build_dynamic_cast_1): Do not call resolve_offset_ref.
* semantics.c (finish_increment_expr): Likewise.
(finish_typeof): Likewise.
* tree.c (lvalue_p_1): Do not handle OFFSET_REF.
* typeck.c (require_complete_type): Do not handle OFFSET_REFs.
(decay_conversion): Do not call resolve_offset_ref.
(finish_class_member_access_expr): Likewise.
(convert_arguments): Likewise.
(build_x_binary_op): Handle DOTSTAR_EXPR.
(condition_conversion): Do not call resolve_offset_ref.
(unary_complex_lvalue): Likewise.
(build_static_cast): Likewise.
(build_reinterpret_cast): Likewise.
(build_const_cast): Likewise.
(build_c_cast): Likewise.
(build_modify_expr): Likewise.
(convert_for_assignment): Likewise.
(convert_for_initialization): Likewise.
* typeck2.c (build_x_arrow): Likewise.
(build_m_component_ref): Simplify.
* g++.old-deja/g++.jason/typeid1.C: Add dg-error marker.
* g++.old-deja/g++.mike/net36.C: Tweak error messages.
From-SVN: r68911
Diffstat (limited to 'gcc/cp/cvt.c')
-rw-r--r-- | gcc/cp/cvt.c | 54 |
1 files changed, 30 insertions, 24 deletions
diff --git a/gcc/cp/cvt.c b/gcc/cp/cvt.c index 29f02226af0..24a3416d42c 100644 --- a/gcc/cp/cvt.c +++ b/gcc/cp/cvt.c @@ -109,24 +109,26 @@ cp_convert_to_pointer (tree type, tree expr, bool force) functions. */ if (TYPE_PTRMEMFUNC_P (intype)) { - tree fntype = TREE_TYPE (TYPE_PTRMEMFUNC_FN_TYPE (intype)); - tree decl = maybe_dummy_object (TYPE_METHOD_BASETYPE (fntype), 0); - expr = build (OFFSET_REF, fntype, decl, expr); + if (pedantic || warn_pmf2ptr) + pedwarn ("converting from `%T' to `%T'", intype, type); + if (TREE_CODE (expr) == PTRMEM_CST) + expr = build_address (PTRMEM_CST_MEMBER (expr)); + else + { + tree decl = maybe_dummy_object (TYPE_PTRMEM_CLASS_TYPE (intype), + 0); + decl = build_address (decl); + expr = get_member_function_from_ptrfunc (&decl, expr); + } } - - if (TREE_CODE (expr) == OFFSET_REF - && TREE_CODE (TREE_TYPE (expr)) == METHOD_TYPE) - expr = resolve_offset_ref (expr); - if (TREE_CODE (TREE_TYPE (expr)) == METHOD_TYPE) - expr = build_addr_func (expr); - if (TREE_CODE (TREE_TYPE (expr)) == POINTER_TYPE) + else if (TREE_CODE (TREE_TYPE (expr)) == METHOD_TYPE) { - if (TREE_CODE (TREE_TYPE (TREE_TYPE (expr))) == METHOD_TYPE) - if (pedantic || warn_pmf2ptr) - pedwarn ("converting from `%T' to `%T'", TREE_TYPE (expr), - type); - return build1 (NOP_EXPR, type, expr); + if (pedantic || warn_pmf2ptr) + pedwarn ("converting from `%T' to `%T'", intype, type); + expr = build_addr_func (expr); } + if (TREE_CODE (TREE_TYPE (expr)) == POINTER_TYPE) + return build_nop (type, expr); intype = TREE_TYPE (expr); } @@ -233,6 +235,19 @@ cp_convert_to_pointer (tree type, tree expr, bool force) return build_ptrmemfunc (TYPE_PTRMEMFUNC_FN_TYPE (type), expr, 0); else if (TYPE_PTRMEMFUNC_P (intype)) { + if (!warn_pmf2ptr) + { + if (TREE_CODE (expr) == PTRMEM_CST) + return cp_convert_to_pointer (type, + PTRMEM_CST_MEMBER (expr), + force); + else if (TREE_CODE (expr) == OFFSET_REF) + { + tree object = TREE_OPERAND (expr, 0); + return get_member_function_from_ptrfunc (&object, + TREE_OPERAND (expr, 1)); + } + } error ("cannot convert `%E' from type `%T' to type `%T'", expr, intype, type); return error_mark_node; @@ -663,9 +678,6 @@ ocp_convert (tree type, tree expr, int convtype, int flags) code = TREE_CODE (type); } - if (TREE_CODE (e) == OFFSET_REF) - e = resolve_offset_ref (e); - if (INTEGRAL_CODE_P (code)) { tree intype = TREE_TYPE (e); @@ -879,10 +891,6 @@ convert_to_void (tree expr, const char *implicit) break; } - case OFFSET_REF: - expr = resolve_offset_ref (expr); - break; - default:; } { @@ -1023,8 +1031,6 @@ build_expr_type_conversion (int desires, tree expr, bool complain) && !(desires & WANT_NULL)) warning ("converting NULL to non-pointer type"); - if (TREE_CODE (expr) == OFFSET_REF) - expr = resolve_offset_ref (expr); expr = convert_from_reference (expr); basetype = TREE_TYPE (expr); |