aboutsummaryrefslogtreecommitdiff
path: root/gcc/fold-const.c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2016-06-08 14:57:26 +0200
committerJakub Jelinek <jakub@gcc.gnu.org>2016-06-08 14:57:26 +0200
commit988c115ca0fee432e5d6823a44e3289c0b73ad15 (patch)
tree890951bd2d7f413e5846a19196d7dc0c3db20bd6 /gcc/fold-const.c
parent867a0126bcb8e2ea2b9ef900ac8b6b75c4fc6382 (diff)
downloadgcc-988c115ca0fee432e5d6823a44e3289c0b73ad15.zip
gcc-988c115ca0fee432e5d6823a44e3289c0b73ad15.tar.gz
gcc-988c115ca0fee432e5d6823a44e3289c0b73ad15.tar.bz2
re PR c++/71448 (pointer relational comparison fails inside constant expression)
PR c++/71448 * fold-const.c (fold_comparison): Handle CONSTANT_CLASS_P (base0) the same as DECL_P (base0) for indirect_base0. Use equality_code in one further place. * g++.dg/torture/pr71448.C: New test. Co-Authored-By: Richard Biener <rguenther@suse.de> From-SVN: r237212
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r--gcc/fold-const.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index 0efa9d5..0b7ea82 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -8527,9 +8527,9 @@ fold_comparison (location_t loc, enum tree_code code, tree type,
if ((offset0 == offset1
|| (offset0 && offset1
&& operand_equal_p (offset0, offset1, 0)))
- && (code == EQ_EXPR
- || code == NE_EXPR
- || (indirect_base0 && DECL_P (base0))
+ && (equality_code
+ || (indirect_base0
+ && (DECL_P (base0) || CONSTANT_CLASS_P (base0)))
|| POINTER_TYPE_OVERFLOW_UNDEFINED))
{
@@ -8568,7 +8568,8 @@ fold_comparison (location_t loc, enum tree_code code, tree type,
6.5.6/8 and /9 with respect to the signed ptrdiff_t. */
else if (bitpos0 == bitpos1
&& (equality_code
- || (indirect_base0 && DECL_P (base0))
+ || (indirect_base0
+ && (DECL_P (base0) || CONSTANT_CLASS_P (base0)))
|| POINTER_TYPE_OVERFLOW_UNDEFINED))
{
/* By converting to signed sizetype we cover middle-end pointer