aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2018-04-27 13:09:17 -0400
committerJason Merrill <jason@gcc.gnu.org>2018-04-27 13:09:17 -0400
commitd760b06868d660bc4b934caf64d2e0a5e69193d1 (patch)
tree584dba85331764d45d1a70a628643945b8bab7e9 /gcc
parenta6e34898d1e8920cc68d2089e45434c9703a77d0 (diff)
downloadgcc-d760b06868d660bc4b934caf64d2e0a5e69193d1.zip
gcc-d760b06868d660bc4b934caf64d2e0a5e69193d1.tar.gz
gcc-d760b06868d660bc4b934caf64d2e0a5e69193d1.tar.bz2
cvt.c (cp_fold_convert): Use convert_ptrmem.
* cvt.c (cp_fold_convert): Use convert_ptrmem. * typeck.c (convert_ptrmem): Add a NOP even if no adjustment. From-SVN: r259717
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog5
-rw-r--r--gcc/cp/cvt.c14
-rw-r--r--gcc/cp/typeck.c7
3 files changed, 18 insertions, 8 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 552828f..2dbc675 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,8 @@
+2018-04-27 Jason Merrill <jason@redhat.com>
+
+ * cvt.c (cp_fold_convert): Use convert_ptrmem.
+ * typeck.c (convert_ptrmem): Add a NOP even if no adjustment.
+
2018-04-27 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/84691
diff --git a/gcc/cp/cvt.c b/gcc/cp/cvt.c
index 0f045e2..d9e3cb5 100644
--- a/gcc/cp/cvt.c
+++ b/gcc/cp/cvt.c
@@ -601,16 +601,20 @@ cp_fold_convert (tree type, tree expr)
tree conv;
if (TREE_TYPE (expr) == type)
conv = expr;
- else if (TREE_CODE (expr) == PTRMEM_CST)
+ else if (TREE_CODE (expr) == PTRMEM_CST
+ && same_type_p (TYPE_PTRMEM_CLASS_TYPE (type),
+ PTRMEM_CST_CLASS (expr)))
{
/* Avoid wrapping a PTRMEM_CST in NOP_EXPR. */
conv = copy_node (expr);
TREE_TYPE (conv) = type;
}
- else if (TREE_CODE (expr) == CONSTRUCTOR
- && TYPE_PTRMEMFUNC_P (type))
- conv = build_ptrmemfunc (TYPE_PTRMEMFUNC_FN_TYPE (type), expr,
- true, false, tf_warning_or_error);
+ else if (TYPE_PTRMEM_P (type))
+ {
+ conv = convert_ptrmem (type, expr, true, false,
+ tf_warning_or_error);
+ conv = cp_fully_fold (conv);
+ }
else
{
conv = fold_convert (type, expr);
diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index 19db315..05ae00e 100644
--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -6844,15 +6844,16 @@ convert_ptrmem (tree type, tree expr, bool allow_inverse_p,
if (TYPE_PTRDATAMEM_P (type))
{
+ tree obase = TYPE_PTRMEM_CLASS_TYPE (TREE_TYPE (expr));
+ tree nbase = TYPE_PTRMEM_CLASS_TYPE (type);
tree delta = (get_delta_difference
- (TYPE_PTRMEM_CLASS_TYPE (TREE_TYPE (expr)),
- TYPE_PTRMEM_CLASS_TYPE (type),
+ (obase, nbase,
allow_inverse_p, c_cast_p, complain));
if (delta == error_mark_node)
return error_mark_node;
- if (!integer_zerop (delta))
+ if (!same_type_p (obase, nbase))
{
if (TREE_CODE (expr) == PTRMEM_CST)
expr = cplus_expand_constant (expr);