From 781ff3d80e88d7d0df019eb3e82ef2a3fb64429c Mon Sep 17 00:00:00 2001 From: Martin Sebor Date: Mon, 18 Jun 2018 16:32:59 +0000 Subject: 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 --- gcc/doc/extend.texi | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'gcc/doc/extend.texi') diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi index ca96c08..cf88175 100644 --- a/gcc/doc/extend.texi +++ b/gcc/doc/extend.texi @@ -11255,6 +11255,7 @@ is called and the @var{flag} argument passed to it. @findex strncmp @findex strncpy @findex strndup +@findex strnlen @findex strpbrk @findex strrchr @findex strspn @@ -11338,8 +11339,8 @@ Outside strict ISO C mode (@option{-ansi}, @option{-std=c90}, @code{significandl}, @code{significand}, @code{sincosf}, @code{sincosl}, @code{sincos}, @code{stpcpy}, @code{stpncpy}, @code{strcasecmp}, @code{strdup}, @code{strfmon}, @code{strncasecmp}, -@code{strndup}, @code{toascii}, @code{y0f}, @code{y0l}, @code{y0}, -@code{y1f}, @code{y1l}, @code{y1}, @code{ynf}, @code{ynl} and +@code{strndup}, @code{strnlen}, @code{toascii}, @code{y0f}, @code{y0l}, +@code{y0}, @code{y1f}, @code{y1l}, @code{y1}, @code{ynf}, @code{ynl} and @code{yn} may be handled as built-in functions. All these functions have corresponding versions -- cgit v1.1