From: Jason Merrill Date: Thu, 24 Aug 2000 20:43:51 +0000 (-0400) Subject: typeck.c (build_ptrmemfunc): Just reinterpret if there's no adjustment necessary. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=3f2b640a7a144e5ae52a84c3217abdccc5bdb199;p=gcc.git typeck.c (build_ptrmemfunc): Just reinterpret if there's no adjustment necessary. * typeck.c (build_ptrmemfunc): Just reinterpret if there's no adjustment necessary. From-SVN: r35954 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 20a8f798ef8..9028c79bd09 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2000-08-24 Jason Merrill + + * typeck.c (build_ptrmemfunc): Just reinterpret if there's no + adjustment necessary. + 2000-08-24 Greg McGary * cp-tree.h (MAIN_NAME_P): Remove macro. diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index 3b3313deede..964993d9392 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -6125,12 +6125,21 @@ build_ptrmemfunc (type, pfn, force) cp_error ("invalid conversion to type `%T' from type `%T'", to_type, pfn_type); + n = get_delta_difference (TYPE_PTRMEMFUNC_OBJECT_TYPE (pfn_type), + TYPE_PTRMEMFUNC_OBJECT_TYPE (to_type), + force); + /* We don't have to do any conversion to convert a pointer-to-member to its own type. But, we don't want to just return a PTRMEM_CST if there's an explicit cast; that cast should make the expression an invalid template argument. */ - if (TREE_CODE (pfn) != PTRMEM_CST && same_type_p (to_type, pfn_type)) - return pfn; + if (TREE_CODE (pfn) != PTRMEM_CST) + { + if (same_type_p (to_type, pfn_type)) + return pfn; + else if (integer_zerop (n)) + return build_reinterpret_cast (to_type, pfn); + } if (TREE_SIDE_EFFECTS (pfn)) pfn = save_expr (pfn); @@ -6142,9 +6151,6 @@ build_ptrmemfunc (type, pfn, force) npfn = build_component_ref (pfn, pfn_identifier, NULL_TREE, 0); delta = build_component_ref (pfn, delta_identifier, NULL_TREE, 0); delta = cp_convert (ptrdiff_type_node, delta); - n = get_delta_difference (TYPE_PTRMEMFUNC_OBJECT_TYPE (pfn_type), - TYPE_PTRMEMFUNC_OBJECT_TYPE (to_type), - force); delta = cp_build_binary_op (PLUS_EXPR, delta, n); return build_ptrmemfunc1 (to_type, delta, NULL_TREE, npfn, NULL_TREE); @@ -6173,9 +6179,6 @@ build_ptrmemfunc (type, pfn, force) idx = build_component_ref (pfn, index_identifier, NULL_TREE, 0); } - n = get_delta_difference (TYPE_PTRMEMFUNC_OBJECT_TYPE (pfn_type), - TYPE_PTRMEMFUNC_OBJECT_TYPE (to_type), - force); delta = cp_build_binary_op (PLUS_EXPR, ndelta, n); delta2 = cp_build_binary_op (PLUS_EXPR, ndelta2, n); e1 = fold (build (GT_EXPR, boolean_type_node, idx, integer_zero_node));