aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Sandiford <richard.sandiford@linaro.org>2017-09-21 11:06:48 +0000
committerRichard Sandiford <rsandifo@gcc.gnu.org>2017-09-21 11:06:48 +0000
commit2e89be4857edfbbcfcca261079c868d70341feb1 (patch)
treeee231ccdf565d1f70e11d3f988284a4572f8f0ff
parent4a77e8874709d7848e4216c59089ccce756f228e (diff)
downloadgcc-2e89be4857edfbbcfcca261079c868d70341feb1.zip
gcc-2e89be4857edfbbcfcca261079c868d70341feb1.tar.gz
gcc-2e89be4857edfbbcfcca261079c868d70341feb1.tar.bz2
Fix unguarded uses of tree_to_uhwi
This patch uses tree_fits_uhwi_p to protect a previously unguarded use of tree_to_uhwi. Previously we would ICE for variable-sized types. 2017-09-20 Richard Sandiford <richard.sandiford@linaro.org> Alan Hayward <alan.hayward@arm.com> David Sherwood <david.sherwood@arm.com> gcc/ * tree.c (find_atomic_core_type): Check tree_fits_uhwi_p before calling tree_to_uhwi. Co-Authored-By: Alan Hayward <alan.hayward@arm.com> Co-Authored-By: David Sherwood <david.sherwood@arm.com> From-SVN: r253057
-rw-r--r--gcc/ChangeLog7
-rw-r--r--gcc/tree.c5
2 files changed, 9 insertions, 3 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 6f2f3d7..a8d78c7 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -2,6 +2,13 @@
Alan Hayward <alan.hayward@arm.com>
David Sherwood <david.sherwood@arm.com>
+ * tree.c (find_atomic_core_type): Check tree_fits_uhwi_p before
+ calling tree_to_uhwi.
+
+2017-09-21 Richard Sandiford <richard.sandiford@linaro.org>
+ Alan Hayward <alan.hayward@arm.com>
+ David Sherwood <david.sherwood@arm.com>
+
* tree-ssa-ccp.c (get_value_for_expr): Use a positive test for
INTEGER_CST rather than a negative test for ADDR_EXPR.
diff --git a/gcc/tree.c b/gcc/tree.c
index 788a84b..e379940 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -5821,11 +5821,10 @@ find_atomic_core_type (tree type)
tree base_atomic_type;
/* Only handle complete types. */
- if (TYPE_SIZE (type) == NULL_TREE)
+ if (!tree_fits_uhwi_p (TYPE_SIZE (type)))
return NULL_TREE;
- HOST_WIDE_INT type_size = tree_to_uhwi (TYPE_SIZE (type));
- switch (type_size)
+ switch (tree_to_uhwi (TYPE_SIZE (type)))
{
case 8:
base_atomic_type = atomicQI_type_node;