diff options
author | Jason Merrill <jason@redhat.com> | 2000-08-24 16:43:51 -0400 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2000-08-24 16:43:51 -0400 |
commit | 3f2b640a7a144e5ae52a84c3217abdccc5bdb199 (patch) | |
tree | 08028cb0ac34171906f304a6017d3b9dfb750a9d /gcc/cp/typeck.c | |
parent | 40e8cc959cbf470b4ef44fd93e329e84d4ff760a (diff) | |
download | gcc-3f2b640a7a144e5ae52a84c3217abdccc5bdb199.zip gcc-3f2b640a7a144e5ae52a84c3217abdccc5bdb199.tar.gz gcc-3f2b640a7a144e5ae52a84c3217abdccc5bdb199.tar.bz2 |
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
Diffstat (limited to 'gcc/cp/typeck.c')
-rw-r--r-- | gcc/cp/typeck.c | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index 3b3313d..964993d 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)); |