PR tree-optimization/81384 - built-in form of strnlen missing
authorMartin Sebor <msebor@redhat.com>
Mon, 18 Jun 2018 16:32:59 +0000 (16:32 +0000)
committerMartin Sebor <msebor@gcc.gnu.org>
Mon, 18 Jun 2018 16:32:59 +0000 (10:32 -0600)
commit781ff3d80e88d7d0df019eb3e82ef2a3fb64429c
tree01c31801fe48b1c21114b772785de9eefe119e7b
parent7314856c61938db90d66f4cead8e4df73ea5d3af
PR tree-optimization/81384 - built-in form of strnlen missing

gcc/ChangeLog:

PR tree-optimization/81384
* builtin-types.def (BT_FN_SIZE_CONST_STRING_SIZE): New.
* builtins.c (expand_builtin_strnlen): New function.
(expand_builtin): Call it.
(fold_builtin_n): Avoid setting TREE_NO_WARNING.
* builtins.def (BUILT_IN_STRNLEN): New.
* calls.c (maybe_warn_nonstring_arg): Handle BUILT_IN_STRNLEN.
Warn for bounds in excess of maximum object size.
* tree-ssa-strlen.c (maybe_set_strlen_range): Return tree representing
single-value ranges.  Handle strnlen.
(handle_builtin_strlen): Handle strnlen.
(strlen_check_and_optimize_stmt): Same.
* doc/extend.texi (Other Builtins): Document strnlen.

gcc/testsuite/ChangeLog:

PR tree-optimization/81384
* gcc.c-torture/execute/builtins/lib/strnlen.c: New test.
* gcc.c-torture/execute/builtins/strnlen-lib.c: New test.
* gcc.c-torture/execute/builtins/strnlen.c: New test.
* gcc.dg/attr-nonstring-2.c: New test.
* gcc.dg/attr-nonstring-3.c: New test.
* gcc.dg/attr-nonstring-4.c: New test.
* gcc.dg/strlenopt-45.c: New test.
* gcc.dg/strlenopt.h (strnlen):  Declare.

From-SVN: r261705
17 files changed:
gcc/ChangeLog
gcc/builtin-types.def
gcc/builtins.c
gcc/builtins.def
gcc/calls.c
gcc/doc/extend.texi
gcc/testsuite/ChangeLog
gcc/testsuite/c-c++-common/attr-nonstring-3.c
gcc/testsuite/gcc.c-torture/execute/builtins/lib/strnlen.c [new file with mode: 0644]
gcc/testsuite/gcc.c-torture/execute/builtins/strnlen-lib.c [new file with mode: 0644]
gcc/testsuite/gcc.c-torture/execute/builtins/strnlen.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/attr-nonstring-2.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/attr-nonstring-3.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/attr-nonstring-4.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/strlenopt-45.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/strlenopt.h
gcc/tree-ssa-strlen.c