From c8d167eac658955482111243ec9f93e3bcb46ca1 Mon Sep 17 00:00:00 2001 From: David Malcolm Date: Tue, 27 Jun 2023 17:21:02 -0400 Subject: [PATCH 89/98] FIXME: add gcc/testsuite/c-c++-common/analyzer/strcspn-1.c --- .../c-c++-common/analyzer/strcspn-1.c | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 gcc/testsuite/c-c++-common/analyzer/strcspn-1.c diff --git a/gcc/testsuite/c-c++-common/analyzer/strcspn-1.c b/gcc/testsuite/c-c++-common/analyzer/strcspn-1.c new file mode 100644 index 000000000000..7fea69650600 --- /dev/null +++ b/gcc/testsuite/c-c++-common/analyzer/strcspn-1.c @@ -0,0 +1,39 @@ +/* See e.g. https://en.cppreference.com/w/c/string/byte/strcspn + and https://man7.org/linux/man-pages/man3/strcspn.3p.html */ + +extern size_t strcspn (const char *dest, const char *src); + +size_t +test_passthrough (const char *dest, const char *src); +{ + return strcspn (dest, src); +} + +size_t +test_null_dest (const char *src); +{ + return strcspn (NULL, src); // FIXME: complain about this? +} + +size_t +test_null_src (const char *dest; +{ + return strcspn (dest, NULL); // FIXME: complain about this? +} + +/* TODO + + "Returns the length of the maximum initial segment of the null-terminated byte string pointed to by dest, that consists of only the characters not found in the null-terminated byte string pointed to by src. + +The behavior is undefined if either dest or src is not a pointer to a null-terminated byte string. +Parameters +dest - pointer to the null-terminated byte string to be analyzed +src - pointer to the null-terminated byte string that contains the characters to search for +Return value + +The length of the maximum initial segment that contains only characters not found in the null-terminated byte string pointed to by src +Notes + +The function name stands for "complementary span" because the function searches for characters not found in src, that is the complement of src." + + */ -- 2.49.0