aboutsummaryrefslogtreecommitdiff
path: root/gcc/fold-const.c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2019-02-21 00:01:41 +0100
committerJakub Jelinek <jakub@gcc.gnu.org>2019-02-21 00:01:41 +0100
commitcd56fb7957a9b2b685f7dec2db6307bde5a0d4f0 (patch)
tree07ffe1091210a8bbe5c67b162c409fec3ac87f3d /gcc/fold-const.c
parentb2d6c9e88c22c18b1109bb39f265f64fffdbb901 (diff)
downloadgcc-cd56fb7957a9b2b685f7dec2db6307bde5a0d4f0.zip
gcc-cd56fb7957a9b2b685f7dec2db6307bde5a0d4f0.tar.gz
gcc-cd56fb7957a9b2b685f7dec2db6307bde5a0d4f0.tar.bz2
re PR middle-end/89091 (ICE: Segmentation fault (in tree_class_check))
PR middle-end/89091 * fold-const.c (decode_field_reference): Return NULL_TREE if lang_hooks.types.type_for_size returns NULL. Check it before overwriting *exp_. Use return NULL_TREE instead of return 0. * gcc.dg/torture/pr89091.c: New test. Co-Authored-By: David Malcolm <dmalcolm@redhat.com> From-SVN: r269056
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r--gcc/fold-const.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index fcc1c45..b019a91 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -4280,7 +4280,7 @@ decode_field_reference (location_t loc, tree *exp_, HOST_WIDE_INT *pbitsize,
There are problems with FP fields since the type_for_size call
below can fail for, e.g., XFmode. */
if (! INTEGRAL_TYPE_P (TREE_TYPE (exp)))
- return 0;
+ return NULL_TREE;
/* We are interested in the bare arrangement of bits, so strip everything
that doesn't affect the machine mode. However, record the type of the
@@ -4296,7 +4296,7 @@ decode_field_reference (location_t loc, tree *exp_, HOST_WIDE_INT *pbitsize,
exp = TREE_OPERAND (exp, 0);
STRIP_NOPS (exp); STRIP_NOPS (and_mask);
if (TREE_CODE (and_mask) != INTEGER_CST)
- return 0;
+ return NULL_TREE;
}
poly_int64 poly_bitsize, poly_bitpos;
@@ -4312,7 +4312,11 @@ decode_field_reference (location_t loc, tree *exp_, HOST_WIDE_INT *pbitsize,
|| (! AGGREGATE_TYPE_P (TREE_TYPE (inner))
&& compare_tree_int (TYPE_SIZE (TREE_TYPE (inner)),
*pbitpos + *pbitsize) < 0))
- return 0;
+ return NULL_TREE;
+
+ unsigned_type = lang_hooks.types.type_for_size (*pbitsize, 1);
+ if (unsigned_type == NULL_TREE)
+ return NULL_TREE;
*exp_ = exp;
@@ -4323,7 +4327,6 @@ decode_field_reference (location_t loc, tree *exp_, HOST_WIDE_INT *pbitsize,
*punsignedp = TYPE_UNSIGNED (outer_type);
/* Compute the mask to access the bitfield. */
- unsigned_type = lang_hooks.types.type_for_size (*pbitsize, 1);
precision = TYPE_PRECISION (unsigned_type);
mask = build_int_cst_type (unsigned_type, -1);