diff options
author | marxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4> | 2016-11-02 09:56:04 +0000 |
---|---|---|
committer | marxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4> | 2016-11-02 09:56:04 +0000 |
commit | 5e0b5f0837453c064501868e6835e748fa33db2c (patch) | |
tree | 88f8e06a5ca6d90a71dcd9af175cf48eaabe4895 | |
parent | 5e922e433f5f6da3731bf657529d08d5efa74621 (diff) | |
download | gcc-5e0b5f0837453c064501868e6835e748fa33db2c.tar.gz |
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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@241780 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | gcc/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/fold-const-call.c | 4 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/tree-ssa/builtins-folding-gimple-ub.c | 4 |
4 files changed, 17 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index ba76566850d..1b74bd2f686 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2016-11-02 Martin Liska <mliska@suse.cz> + + * fold-const-call.c (host_size_t_cst_p): Test whether + t is convertible to size_t. + 2016-11-02 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR tree-optimization/78170 diff --git a/gcc/fold-const-call.c b/gcc/fold-const-call.c index 05a15f974e9..1b3a755df34 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); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index c06c315821e..38668b74c8b 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2016-11-02 Martin Liska <mliska@suse.cz> + + * gcc.dg/tree-ssa/builtins-folding-gimple-ub.c (main): Add + test case. + 2016-11-02 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR tree-optimization/78170 diff --git a/gcc/testsuite/gcc.dg/tree-ssa/builtins-folding-gimple-ub.c b/gcc/testsuite/gcc.dg/tree-ssa/builtins-folding-gimple-ub.c index df0ede2ba5e..e1658d183c3 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/builtins-folding-gimple-ub.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/builtins-folding-gimple-ub.c @@ -17,6 +17,10 @@ main (void) if (__builtin_memchr (foo1, 'x', 1000)) /* Not folded away. */ __builtin_abort (); + /* STRNCMP. */ + if (strncmp ("a", "b", -1)) /* { dg-warning "implicit declaration of function" } */ + __builtin_abort (); + return 0; } |