diff options
author | Jason Merrill <jason@redhat.com> | 2018-04-27 13:09:17 -0400 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2018-04-27 13:09:17 -0400 |
commit | d760b06868d660bc4b934caf64d2e0a5e69193d1 (patch) | |
tree | 584dba85331764d45d1a70a628643945b8bab7e9 /gcc/cp/cvt.c | |
parent | a6e34898d1e8920cc68d2089e45434c9703a77d0 (diff) | |
download | gcc-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/cp/cvt.c')
-rw-r--r-- | gcc/cp/cvt.c | 14 |
1 files changed, 9 insertions, 5 deletions
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); |