diff options
author | Bernd Edlinger <bernd.edlinger@hotmail.de> | 2018-09-14 01:49:38 +0000 |
---|---|---|
committer | Jeff Law <law@gcc.gnu.org> | 2018-09-13 19:49:38 -0600 |
commit | d01b568a78351beb6b693b613e6b48bcb2475eae (patch) | |
tree | bd7da348cd6459bb6656e42300e83dcf9f2ac2c2 /gcc/gimple-fold.c | |
parent | 9a9f692b6c0c8b93b7fda00c60c6e30c2e6551ce (diff) | |
download | gcc-d01b568a78351beb6b693b613e6b48bcb2475eae.zip gcc-d01b568a78351beb6b693b613e6b48bcb2475eae.tar.gz gcc-d01b568a78351beb6b693b613e6b48bcb2475eae.tar.bz2 |
builtins.c (c_strlen): Handle not zero terminated STRING_CSTs correctly.
* builtins.c (c_strlen): Handle not zero terminated STRING_CSTs
correctly.
* fold-const.c (c_getstr): Fix function comment. Remove unused third
argument. Fix range checks.
* fold-const.h (c_getstr): Adjust protoype.
* gimple-fold.c (gimple_fold_builtin_memory_op): Avoid folding when
string is constant but contains no NUL byte.
From-SVN: r264301
Diffstat (limited to 'gcc/gimple-fold.c')
-rw-r--r-- | gcc/gimple-fold.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/gcc/gimple-fold.c b/gcc/gimple-fold.c index cbca6a9..8323051 100644 --- a/gcc/gimple-fold.c +++ b/gcc/gimple-fold.c @@ -725,6 +725,8 @@ gimple_fold_builtin_memory_op (gimple_stmt_iterator *gsi, tree srctype, desttype; unsigned int src_align, dest_align; tree off0; + const char *tmp_str; + unsigned HOST_WIDE_INT tmp_len; /* Build accesses at offset zero with a ref-all character type. */ off0 = build_int_cst (build_pointer_type_for_mode (char_type_node, @@ -742,7 +744,9 @@ gimple_fold_builtin_memory_op (gimple_stmt_iterator *gsi, confuses the tree-ssa-strlen.c. This doesn't handle the case in gcc.dg/strlenopt-8.c which is XFAILed for that reason. */ - && !c_strlen (src, 2)) + && !c_strlen (src, 2) + && !((tmp_str = c_getstr (src, &tmp_len)) != NULL + && memchr (tmp_str, 0, tmp_len) == NULL)) { unsigned ilen = tree_to_uhwi (len); if (pow2p_hwi (ilen)) |