aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2019-06-18 12:08:17 -0400
committerJason Merrill <jason@gcc.gnu.org>2019-06-18 12:08:17 -0400
commit02a8575c0cc6cc0004afaee095185775cd61f080 (patch)
treec77eb4a74973d6b6da551ab8c349b008f1d8de29
parent3da7d774259904b351febd2c2de4eb15cd262ff5 (diff)
downloadgcc-02a8575c0cc6cc0004afaee095185775cd61f080.zip
gcc-02a8575c0cc6cc0004afaee095185775cd61f080.tar.gz
gcc-02a8575c0cc6cc0004afaee095185775cd61f080.tar.bz2
Handle constexpr conversion from and then to the same type.
* constexpr.c (cxx_eval_constant_expression): Handle conversion from and then to the same type. From-SVN: r272429
-rw-r--r--gcc/cp/ChangeLog5
-rw-r--r--gcc/cp/constexpr.c12
2 files changed, 15 insertions, 2 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index eb795b8..4f26dc3 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,10 @@
2019-06-18 Jason Merrill <jason@redhat.com>
+ * constexpr.c (cxx_eval_constant_expression): Handle conversion from
+ and then to the same type.
+
+2019-06-18 Jason Merrill <jason@redhat.com>
+
* constexpr.c (unshare_constructor): Add MEM_STAT_DECL.
2019-06-17 Jakub Jelinek <jakub@redhat.com>
diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c
index 22901f8..0f68a0c 100644
--- a/gcc/cp/constexpr.c
+++ b/gcc/cp/constexpr.c
@@ -5034,6 +5034,10 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t,
if (*non_constant_p)
return t;
tree type = TREE_TYPE (t);
+
+ if (VOID_TYPE_P (type))
+ return void_node;
+
if (TREE_CODE (op) == PTRMEM_CST
&& !TYPE_PTRMEM_P (type))
op = cplus_expand_constant (op);
@@ -5094,14 +5098,18 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t,
conversion. */
return fold (t);
+ tree sop;
+
/* Handle an array's bounds having been deduced after we built
the wrapping expression. */
if (same_type_ignoring_tlq_and_bounds_p (type, TREE_TYPE (op)))
r = op;
+ else if (sop = tree_strip_nop_conversions (op),
+ sop != op && (same_type_ignoring_tlq_and_bounds_p
+ (type, TREE_TYPE (sop))))
+ r = sop;
else if (tcode == UNARY_PLUS_EXPR)
r = fold_convert (TREE_TYPE (t), op);
- else if (VOID_TYPE_P (type))
- r = void_node;
else
r = fold_build1 (tcode, type, op);