aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2014-11-18 14:09:55 -0500
committerJason Merrill <jason@gcc.gnu.org>2014-11-18 14:09:55 -0500
commitac2f8d26b5a601186735d1341eaec7779e9fa7fe (patch)
tree22d1fcaf625bb8242c9bdcfce0bbeb522fbd196d /gcc/cp
parentcafc9af2ea70fde45b287625de68423a233a24d9 (diff)
downloadgcc-ac2f8d26b5a601186735d1341eaec7779e9fa7fe.zip
gcc-ac2f8d26b5a601186735d1341eaec7779e9fa7fe.tar.gz
gcc-ac2f8d26b5a601186735d1341eaec7779e9fa7fe.tar.bz2
re PR c++/63925 (ICE with C++14 constexpr when trying to constexprify std::min)
PR c++/63925 * constexpr.c (cxx_eval_increment_expression): Use POINTER_PLUS_EXPR. From-SVN: r217731
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/ChangeLog3
-rw-r--r--gcc/cp/constexpr.c13
2 files changed, 14 insertions, 2 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 28d8796..0628b42 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,8 @@
2014-11-18 Jason Merrill <jason@redhat.com>
+ PR c++/63925
+ * constexpr.c (cxx_eval_increment_expression): Use POINTER_PLUS_EXPR.
+
PR c++/63934
* constexpr.c (cxx_eval_call_expression): Check DECL_CONSTRUCTOR_P
rather than VOID_TYPE_P.
diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c
index 4325caa..5abea14 100644
--- a/gcc/cp/constexpr.c
+++ b/gcc/cp/constexpr.c
@@ -2566,8 +2566,17 @@ cxx_eval_increment_expression (const constexpr_ctx *ctx, tree t,
/* The modified value. */
bool inc = (code == PREINCREMENT_EXPR || code == POSTINCREMENT_EXPR);
- tree mod = fold_build2 (inc ? PLUS_EXPR : MINUS_EXPR,
- type, val, offset);
+ tree mod;
+ if (POINTER_TYPE_P (type))
+ {
+ /* The middle end requires pointers to use POINTER_PLUS_EXPR. */
+ offset = convert_to_ptrofftype (offset);
+ if (!inc)
+ offset = fold_build1 (NEGATE_EXPR, TREE_TYPE (offset), offset);
+ mod = fold_build2 (POINTER_PLUS_EXPR, type, val, offset);
+ }
+ else
+ mod = fold_build2 (inc ? PLUS_EXPR : MINUS_EXPR, type, val, offset);
VERIFY_CONSTANT (mod);
/* Storing the modified value. */