https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81384
--- Comment #3 from Martin Sebor ---
Author: msebor
Date: Mon Jun 18 16:32:59 2018
New Revision: 261705
URL: https://gcc.gnu.org/viewcvs?rev=261705&root=gcc&view=rev
Log:
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.
Added:
trunk/gcc/testsuite/gcc.c-torture/execute/builtins/lib/strnlen.c
trunk/gcc/testsuite/gcc.c-torture/execute/builtins/strnlen-lib.c
trunk/gcc/testsuite/gcc.c-torture/execute/builtins/strnlen.c
trunk/gcc/testsuite/gcc.dg/attr-nonstring-2.c
trunk/gcc/testsuite/gcc.dg/attr-nonstring-3.c
trunk/gcc/testsuite/gcc.dg/attr-nonstring-4.c
trunk/gcc/testsuite/gcc.dg/strlenopt-45.c
Modified:
trunk/gcc/ChangeLog
trunk/gcc/builtin-types.def
trunk/gcc/builtins.c
trunk/gcc/builtins.def
trunk/gcc/calls.c
trunk/gcc/doc/extend.texi
trunk/gcc/testsuite/ChangeLog
trunk/gcc/testsuite/c-c++-common/attr-nonstring-3.c
trunk/gcc/testsuite/gcc.dg/strlenopt.h
trunk/gcc/tree-ssa-strlen.c