aboutsummaryrefslogtreecommitdiff
path: root/gcc/fold-const-call.c
diff options
context:
space:
mode:
authorMartin Liska <mliska@suse.cz>2016-11-02 10:56:04 +0100
committerMartin Liska <marxin@gcc.gnu.org>2016-11-02 09:56:04 +0000
commit4adbcdb4ba25f10c6ad581688ff6cd8bff070655 (patch)
tree88f8e06a5ca6d90a71dcd9af175cf48eaabe4895 /gcc/fold-const-call.c
parent4b2c06f49f8d7365e2aa15f32cbc6a726c9ff9fb (diff)
downloadgcc-4adbcdb4ba25f10c6ad581688ff6cd8bff070655.zip
gcc-4adbcdb4ba25f10c6ad581688ff6cd8bff070655.tar.gz
gcc-4adbcdb4ba25f10c6ad581688ff6cd8bff070655.tar.bz2
Fix host_size_t_cst_p predicat
* fold-const-call.c (host_size_t_cst_p): Test whether t is convertible to size_t. * gcc.dg/tree-ssa/builtins-folding-gimple-ub.c (main): Add test case. From-SVN: r241780
Diffstat (limited to 'gcc/fold-const-call.c')
-rw-r--r--gcc/fold-const-call.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/gcc/fold-const-call.c b/gcc/fold-const-call.c
index 05a15f9..1b3a755 100644
--- a/gcc/fold-const-call.c
+++ b/gcc/fold-const-call.c
@@ -29,6 +29,7 @@ along with GCC; see the file COPYING3. If not see
#include "case-cfn-macros.h"
#include "tm.h" /* For C[LT]Z_DEFINED_AT_ZERO. */
#include "builtins.h"
+#include "gimple-expr.h"
/* Functions that test for certain constant types, abstracting away the
decision about whether to check for overflow. */
@@ -57,7 +58,8 @@ complex_cst_p (tree t)
static inline bool
host_size_t_cst_p (tree t, size_t *size_out)
{
- if (integer_cst_p (t)
+ if (types_compatible_p (size_type_node, TREE_TYPE (t))
+ && integer_cst_p (t)
&& wi::min_precision (t, UNSIGNED) <= sizeof (size_t) * CHAR_BIT)
{
*size_out = tree_to_uhwi (t);