Fix unguarded uses of tree_to_uhwi
authorRichard Sandiford <richard.sandiford@linaro.org>
Thu, 21 Sep 2017 11:06:48 +0000 (11:06 +0000)
committerRichard Sandiford <rsandifo@gcc.gnu.org>
Thu, 21 Sep 2017 11:06:48 +0000 (11:06 +0000)
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

gcc/ChangeLog
gcc/tree.c

index 6f2f3d7a9df273982bbb9d79d6260d109d7eb3b3..a8d78c7ad58aeda897e17efe01c851281bdc2b55 100644 (file)
@@ -1,3 +1,10 @@
+2017-09-21  Richard Sandiford  <richard.sandiford@linaro.org>
+           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>
index 788a84b511eb30ba31b048483aef028fa46cf310..e379940f35d34996c29b28a400c8fd5f63cff634 100644 (file)
@@ -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;