arguments to support expressions with a comma inside a compound
literal initializer not surrounded by parentheses.
+* For ISO C23, the functions bsearch, memchr, strchr, strpbrk, strrchr,
+ strstr, wcschr, wcspbrk, wcsrchr, wcsstr and wmemchr that return
+ pointers into their input arrays now have definitions as macros that
+ return a pointer to a const-qualified type when the input argument is
+ a pointer to a const-qualified type.
+
* The C23 typedef names long_double_t, _Float32_t, _Float64_t, and (on
platforms supporting _Float128) _Float128_t, introduced in TS
18661-3:2015, have been added to <math.h>.
static inline bool
match (const char *sym, const char *name)
{
- char *p = strchr (sym, '(');
+ const char *p = strchr (sym, '(');
return p != NULL && strstr (p, name) != NULL;
}
This function derives its name from the fact that it is implemented
using the binary search algorithm.
+
+In ISO C23 and later, this function is qualifier-generic:
+that is, it is also implemented as a function-like macro,
+and when the macro is used and @var{array} has a type
+that is a pointer to a @code{const}-qualified object type,
+@code{bsearch} returns @code{const void *}.
+As an obsolescent feature, if the macro is suppressed
+the external function returns @code{void *} regardless.
@end deftypefun
@node Array Sort Function
to an @code{unsigned char}) in the initial @var{size} bytes of the
object beginning at @var{block}. The return value is a pointer to the
located byte, or a null pointer if no match was found.
+
+In ISO C23 and later, this function is qualifier-generic:
+that is, it is also implemented as a function-like macro,
+and when the macro is used and @var{block} has a type
+that is a pointer to a @code{const}-qualified object type,
+@code{memchr} returns @code{const void *}.
+As an obsolescent feature, if the macro is suppressed
+the external function returns @code{void *} regardless.
+The function is also qualifier-generic in C++.
@end deftypefun
@deftypefun {wchar_t *} wmemchr (const wchar_t *@var{block}, wchar_t @var{wc}, size_t @var{size})
in the initial @var{size} wide characters of the object beginning at
@var{block}. The return value is a pointer to the located wide
character, or a null pointer if no match was found.
+
+In ISO C23 and later, this function is qualifier-generic:
+that is, it is also implemented as a function-like macro,
+and when the macro is used and @var{block} has a type
+that is a pointer to a @code{const}-qualified object type,
+@code{wmemchr} returns @code{const wchar_t *}.
+As an obsolescent feature, if the macro is suppressed
+the external function returns @code{wchar_t *} regardless.
+The function is also qualifier-generic in C++.
@end deftypefun
@deftypefun {void *} rawmemchr (const void *@var{block}, int @var{c})
the position of the terminating null byte it has found. If you
need that information, it is better (but less portable) to use
@code{strchrnul} than to search for it a second time.
+
+In ISO C23 and later, this function is qualifier-generic:
+that is, it is also implemented as a function-like macro,
+and when the macro is used and @var{string} has a type
+that is a pointer to a @code{const}-qualified object type,
+@code{strchr} returns @code{const char *}.
+As an obsolescent feature, if the macro is suppressed
+the external function returns @code{char *} regardless.
+The function is also qualifier-generic in C++.
@end deftypefun
@deftypefun {wchar_t *} wcschr (const wchar_t *@var{wstring}, wchar_t @var{wc})
of a wide string by specifying a null wide character as the
value of the @var{wc} argument. It would be better (but less portable)
to use @code{wcschrnul} in this case, though.
+
+In ISO C23 and later, this function is qualifier-generic:
+that is, it is also implemented as a function-like macro,
+and when the macro is used and @var{wstring} has a type
+that is a pointer to a @code{const}-qualified object type,
+@code{wcschr} returns @code{const wchar_t *}.
+As an obsolescent feature, if the macro is suppressed
+the external function returns @code{wchar_t *} regardless.
+The function is also qualifier-generic in C++.
@end deftypefun
@deftypefun {char *} strchrnul (const char *@var{string}, int @var{c})
strrchr ("hello, world", 'l')
@result{} "ld"
@end smallexample
+
+In ISO C23 and later, this function is qualifier-generic:
+that is, it is also implemented as a function-like macro,
+and when the macro is used and @var{string} has a type
+that is a pointer to a @code{const}-qualified object type,
+@code{strrchr} returns @code{const char *}.
+As an obsolescent feature, if the macro is suppressed
+the external function returns @code{char *} regardless.
+The function is also qualifier-generic in C++.
@end deftypefun
@deftypefun {wchar_t *} wcsrchr (const wchar_t *@var{wstring}, wchar_t @var{wc})
The function @code{wcsrchr} is like @code{wcschr}, except that it searches
backwards from the end of the string @var{wstring} (instead of forwards
from the front).
+
+In ISO C23 and later, this function is qualifier-generic:
+that is, it is also implemented as a function-like macro,
+and when the macro is used and @var{wstring} has a type
+that is a pointer to a @code{const}-qualified object type,
+@code{wcsrchr} returns @code{const wchar_t *}.
+As an obsolescent feature, if the macro is suppressed
+the external function returns @code{wchar_t *} regardless.
+The function is also qualifier-generic in C++.
@end deftypefun
@deftypefun {char *} strstr (const char *@var{haystack}, const char *@var{needle})
strstr ("hello, world", "wo")
@result{} "world"
@end smallexample
+
+In ISO C23 and later, this function is qualifier-generic:
+that is, it is also implemented as a function-like macro,
+and when the macro is used and @var{haystack} has a type
+that is a pointer to a @code{const}-qualified object type,
+@code{strstr} returns @code{const char *}.
+As an obsolescent feature, if the macro is suppressed
+the external function returns @code{char *} regardless.
+The function is also qualifier-generic in C++.
@end deftypefun
@deftypefun {wchar_t *} wcsstr (const wchar_t *@var{haystack}, const wchar_t *@var{needle})
returns a pointer into the string @var{haystack} that is the first wide
character of the substring, or a null pointer if no match was found. If
@var{needle} is an empty string, the function returns @var{haystack}.
+
+In ISO C23 and later, this function is qualifier-generic:
+that is, it is also implemented as a function-like macro,
+and when the macro is used and @var{haystack} has a type
+that is a pointer to a @code{const}-qualified object type,
+@code{wcsstr} returns @code{const wchar_t *}.
+As an obsolescent feature, if the macro is suppressed
+the external function returns @code{wchar_t *} regardless.
+The function is also qualifier-generic in C++.
@end deftypefun
@deftypefun {wchar_t *} wcswcs (const wchar_t *@var{haystack}, const wchar_t *@var{needle})
In a multibyte string, characters consisting of
more than one byte are not treated as single entities. Each byte is treated
separately. The function is not locale-dependent.
+
+In ISO C23 and later, this function is qualifier-generic:
+that is, it is also implemented as a function-like macro,
+and when the macro is used and @var{string} has a type
+that is a pointer to a @code{const}-qualified object type,
+@code{strpbrk} returns @code{const char *}.
+As an obsolescent feature, if the macro is suppressed
+the external function returns @code{char *} regardless.
+The function is also qualifier-generic in C++.
@end deftypefun
@deftypefun {wchar_t *} wcspbrk (const wchar_t *@var{wstring}, const wchar_t *@var{stopset})
wide character in @var{wstring} that is a member of the set
@var{stopset} instead of the length of the initial substring. It
returns a null pointer if no such wide character from @var{stopset} is found.
+
+In ISO C23 and later, this function is qualifier-generic:
+that is, it is also implemented as a function-like macro,
+and when the macro is used and @var{wstring} has a type
+that is a pointer to a @code{const}-qualified object type,
+@code{wcspbrk} returns @code{const wchar_t *}.
+As an obsolescent feature, if the macro is suppressed
+the external function returns @code{wchar_t *} regardless.
+The function is also qualifier-generic in C++.
@end deftypefun
# define __HAVE_GENERIC_SELECTION 0
#endif
+#if __HAVE_GENERIC_SELECTION
+/* If PTR is a pointer to const, return CALL cast to type CTYPE,
+ otherwise return CALL. Pointers to types with non-const qualifiers
+ are not valid. This should not be defined for C++, as macros are
+ not an appropriate way of implementing such qualifier-generic
+ operations for C++. */
+# define __glibc_const_generic(PTR, CTYPE, CALL) \
+ _Generic (0 ? (PTR) : (void *) 1, \
+ const void *: (CTYPE) (CALL), \
+ default: CALL)
+#endif
+
#if __GNUC_PREREQ (10, 0)
/* Designates a 1-based positional argument ref-index of pointer type
that can be used to access size-index elements of the pointed-to
tst-canon-bz26341 \
tst-concurrent-exit \
tst-concurrent-quick_exit \
+ tst-const \
tst-cxa_atexit \
tst-environ \
tst-environ-change-1 \
# include <bits/stdlib-bsearch.h>
#endif
+#if __GLIBC_USE (ISOC23) && defined __glibc_const_generic && !defined _LIBC
+# define bsearch(KEY, BASE, NMEMB, SIZE, COMPAR) \
+ __glibc_const_generic (BASE, const void *, \
+ bsearch (KEY, BASE, NMEMB, SIZE, COMPAR))
+#endif
+
/* Sort NMEMB elements of BASE, of SIZE bytes each,
using COMPAR to perform the comparisons. */
extern void qsort (void *__base, size_t __nmemb, size_t __size,
--- /dev/null
+/* Test bsearch const-generic macro.
+ Copyright (C) 2025 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <https://www.gnu.org/licenses/>. */
+
+#include <stdlib.h>
+#include <libc-diag.h>
+
+void *vp;
+const void *cvp;
+int *ip;
+const int *cip;
+size_t sz;
+int (*compar) (const void *, const void *);
+
+#define CHECK_TYPE(EXPR, TYPE) \
+ _Static_assert (_Generic (EXPR, TYPE: 1), "type check")
+
+static int
+do_test (void)
+{
+ /* This is a compilation test. */
+ CHECK_TYPE (bsearch (cvp, cvp, sz, sz, compar), const void *);
+ CHECK_TYPE (bsearch (cvp, vp, sz, sz, compar), void *);
+ CHECK_TYPE (bsearch (vp, cvp, sz, sz, compar), const void *);
+ CHECK_TYPE (bsearch (vp, vp, sz, sz, compar), void *);
+ CHECK_TYPE (bsearch (cvp, cip, sz, sz, compar), const void *);
+ CHECK_TYPE (bsearch (cvp, ip, sz, sz, compar), void *);
+ CHECK_TYPE (bsearch (vp, cip, sz, sz, compar), const void *);
+ CHECK_TYPE (bsearch (vp, ip, sz, sz, compar), void *);
+ DIAG_PUSH_NEEDS_COMMENT;
+ /* This deliberately tests the type of the result with a null
+ pointer constant argument. */
+ DIAG_IGNORE_NEEDS_COMMENT (14, "-Wnonnull");
+ CHECK_TYPE (bsearch (cvp, 0, sz, sz, compar), void *);
+ CHECK_TYPE (bsearch (cvp, (void *) 0, sz, sz, compar), void *);
+ DIAG_POP_NEEDS_COMMENT;
+ CHECK_TYPE ((bsearch) (cvp, cvp, sz, sz, compar), void *);
+ return 0;
+}
+
+#include <support/test-driver.c>
tester \
tst-bswap \
tst-cmp \
+ tst-const \
tst-endian \
tst-inlcall \
tst-memmove-overflow \
#else
extern void *memchr (const void *__s, int __c, size_t __n)
__THROW __attribute_pure__ __nonnull ((1));
+# if __GLIBC_USE (ISOC23) && defined __glibc_const_generic && !defined _LIBC
+# define memchr(S, C, N) \
+ __glibc_const_generic (S, const void *, memchr (S, C, N))
+# endif
#endif
#ifdef __USE_GNU
#else
extern char *strchr (const char *__s, int __c)
__THROW __attribute_pure__ __nonnull ((1));
+# if __GLIBC_USE (ISOC23) && defined __glibc_const_generic && !defined _LIBC
+# define strchr(S, C) \
+ __glibc_const_generic (S, const char *, strchr (S, C))
+# endif
#endif
/* Find the last occurrence of C in S. */
#ifdef __CORRECT_ISO_CPP_STRING_H_PROTO
#else
extern char *strrchr (const char *__s, int __c)
__THROW __attribute_pure__ __nonnull ((1));
+# if __GLIBC_USE (ISOC23) && defined __glibc_const_generic && !defined _LIBC
+# define strrchr(S, C) \
+ __glibc_const_generic (S, const char *, strrchr (S, C))
+# endif
#endif
#ifdef __USE_MISC
#else
extern char *strpbrk (const char *__s, const char *__accept)
__THROW __attribute_pure__ __nonnull ((1, 2));
+# if __GLIBC_USE (ISOC23) && defined __glibc_const_generic && !defined _LIBC
+# define strpbrk(S, ACCEPT) \
+ __glibc_const_generic (S, const char *, strpbrk (S, ACCEPT))
+# endif
#endif
/* Find the first occurrence of NEEDLE in HAYSTACK. */
#ifdef __CORRECT_ISO_CPP_STRING_H_PROTO
#else
extern char *strstr (const char *__haystack, const char *__needle)
__THROW __attribute_pure__ __nonnull ((1, 2));
+# if __GLIBC_USE (ISOC23) && defined __glibc_const_generic && !defined _LIBC
+# define strstr(HAYSTACK, NEEDLE) \
+ __glibc_const_generic (HAYSTACK, const char *, \
+ strstr (HAYSTACK, NEEDLE))
+# endif
#endif
# define libc_hidden_weak(a)
# include "wcsmbs/wmemchr.c"
# define WCSNLEN __wcsnlen_default
+# undef wmemchr
# define wmemchr __wmemchr_default
# include "wcsmbs/wcsnlen.c"
IMPL (__wcsnlen_default, 1)
--- /dev/null
+/* Test <string.h> const-generic macros.
+ Copyright (C) 2025 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <https://www.gnu.org/licenses/>. */
+
+#include <string.h>
+#include <libc-diag.h>
+
+void *vp;
+const void *cvp;
+int *ip;
+const int *cip;
+char *cp;
+const char *ccp;
+int c;
+size_t sz;
+
+#define CHECK_TYPE(EXPR, TYPE) \
+ _Static_assert (_Generic (EXPR, TYPE: 1), "type check")
+
+static int
+do_test (void)
+{
+ /* This is a compilation test. */
+ CHECK_TYPE (memchr (vp, c, sz), void *);
+ CHECK_TYPE (memchr (cvp, c, sz), const void *);
+ CHECK_TYPE (memchr (ip, c, sz), void *);
+ CHECK_TYPE (memchr (cip, c, sz), const void *);
+ CHECK_TYPE (memchr (cp, c, sz), void *);
+ CHECK_TYPE (memchr (ccp, c, sz), const void *);
+ DIAG_PUSH_NEEDS_COMMENT;
+ /* This deliberately tests the type of the result with a null
+ pointer constant argument. */
+ DIAG_IGNORE_NEEDS_COMMENT (14, "-Wnonnull");
+ CHECK_TYPE (memchr (0, c, sz), void *);
+ CHECK_TYPE (memchr ((void *) 0, c, sz), void *);
+ DIAG_POP_NEEDS_COMMENT;
+ CHECK_TYPE ((memchr) (cvp, c, sz), void *);
+ CHECK_TYPE (strchr (vp, c), char *);
+ CHECK_TYPE (strchr (cvp, c), const char *);
+ CHECK_TYPE (strchr (cp, c), char *);
+ CHECK_TYPE (strchr (ccp, c), const char *);
+ DIAG_PUSH_NEEDS_COMMENT;
+ DIAG_IGNORE_NEEDS_COMMENT (14, "-Wnonnull");
+ CHECK_TYPE (strchr (0, c), char *);
+ CHECK_TYPE (strchr ((void *) 0, c), char *);
+ DIAG_POP_NEEDS_COMMENT;
+ CHECK_TYPE ((strchr) (ccp, c), char *);
+ CHECK_TYPE (strpbrk (vp, vp), char *);
+ CHECK_TYPE (strpbrk (vp, cvp), char *);
+ CHECK_TYPE (strpbrk (cvp, vp), const char *);
+ CHECK_TYPE (strpbrk (cvp, cvp), const char *);
+ CHECK_TYPE (strpbrk (cp, cp), char *);
+ CHECK_TYPE (strpbrk (cp, ccp), char *);
+ CHECK_TYPE (strpbrk (ccp, cp), const char *);
+ CHECK_TYPE (strpbrk (ccp, ccp), const char *);
+ DIAG_PUSH_NEEDS_COMMENT;
+ DIAG_IGNORE_NEEDS_COMMENT (14, "-Wnonnull");
+ CHECK_TYPE (strpbrk (0, cp), char *);
+ CHECK_TYPE (strpbrk (0, ccp), char *);
+ CHECK_TYPE (strpbrk ((void *) 0, cp), char *);
+ CHECK_TYPE (strpbrk ((void *) 0, ccp), char *);
+ DIAG_POP_NEEDS_COMMENT;
+ CHECK_TYPE ((strpbrk) (ccp, ccp), char *);
+ CHECK_TYPE (strrchr (vp, c), char *);
+ CHECK_TYPE (strrchr (cvp, c), const char *);
+ CHECK_TYPE (strrchr (cp, c), char *);
+ CHECK_TYPE (strrchr (ccp, c), const char *);
+ DIAG_PUSH_NEEDS_COMMENT;
+ DIAG_IGNORE_NEEDS_COMMENT (14, "-Wnonnull");
+ CHECK_TYPE (strrchr (0, c), char *);
+ CHECK_TYPE (strrchr ((void *) 0, c), char *);
+ DIAG_POP_NEEDS_COMMENT;
+ CHECK_TYPE ((strrchr) (ccp, c), char *);
+ CHECK_TYPE (strstr (vp, vp), char *);
+ CHECK_TYPE (strstr (vp, cvp), char *);
+ CHECK_TYPE (strstr (cvp, vp), const char *);
+ CHECK_TYPE (strstr (cvp, cvp), const char *);
+ CHECK_TYPE (strstr (cp, cp), char *);
+ CHECK_TYPE (strstr (cp, ccp), char *);
+ CHECK_TYPE (strstr (ccp, cp), const char *);
+ CHECK_TYPE (strstr (ccp, ccp), const char *);
+ DIAG_PUSH_NEEDS_COMMENT;
+ DIAG_IGNORE_NEEDS_COMMENT (14, "-Wnonnull");
+ CHECK_TYPE (strstr (0, cp), char *);
+ CHECK_TYPE (strstr (0, ccp), char *);
+ CHECK_TYPE (strstr ((void *) 0, cp), char *);
+ CHECK_TYPE (strstr ((void *) 0, ccp), char *);
+ DIAG_POP_NEEDS_COMMENT;
+ CHECK_TYPE ((strstr) (ccp, ccp), char *);
+ return 0;
+}
+
+#include <support/test-driver.c>
# The -Wno-unused-variable flag is used to prevent GCC 6
# from warning about time_t_min and time_t_max which are
# defined in private.h but not used.
+# -Wno-discarded-qualifiers is because zic is not prepared for C23
+# -qualifier-generic strchr.
CFLAGS-zdump.c += $(tz-cflags)
-CFLAGS-zic.c += $(tz-cflags) -Wno-unused-variable
+CFLAGS-zic.c += $(tz-cflags) -Wno-unused-variable -Wno-discarded-qualifiers
# We have to make sure the data for testing the tz functions is available.
# Don't add leapseconds here since test-tz made checks that work only without
tst-c16-surrogate \
tst-c16c32-1 \
tst-c32-state \
+ tst-const \
tst-fgetwc-after-eof \
tst-mbrtowc \
tst-mbrtowc2 \
--- /dev/null
+/* Test <wchar.h> const-generic macros.
+ Copyright (C) 2025 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <https://www.gnu.org/licenses/>. */
+
+#include <wchar.h>
+
+void *vp;
+const void *cvp;
+wchar_t *wp;
+const wchar_t *cwp;
+size_t sz;
+wchar_t wc;
+
+#define CHECK_TYPE(EXPR, TYPE) \
+ _Static_assert (_Generic (EXPR, TYPE: 1), "type check")
+
+static int
+do_test (void)
+{
+ /* This is a compilation test. */
+ CHECK_TYPE (wmemchr (vp, wc, sz), wchar_t *);
+ CHECK_TYPE (wmemchr (cvp, wc, sz), const wchar_t *);
+ CHECK_TYPE (wmemchr (wp, wc, sz), wchar_t *);
+ CHECK_TYPE (wmemchr (cwp, wc, sz), const wchar_t *);
+ CHECK_TYPE (wmemchr (0, wc, sz), wchar_t *);
+ CHECK_TYPE (wmemchr ((void *) 0, wc, sz), wchar_t *);
+ CHECK_TYPE ((wmemchr) (cwp, wc, sz), wchar_t *);
+ CHECK_TYPE (wcschr (vp, wc), wchar_t *);
+ CHECK_TYPE (wcschr (cvp, wc), const wchar_t *);
+ CHECK_TYPE (wcschr (wp, wc), wchar_t *);
+ CHECK_TYPE (wcschr (cwp, wc), const wchar_t *);
+ CHECK_TYPE (wcschr (0, wc), wchar_t *);
+ CHECK_TYPE (wcschr ((void *) 0, wc), wchar_t *);
+ CHECK_TYPE ((wcschr) (cwp, wc), wchar_t *);
+ CHECK_TYPE (wcspbrk (vp, vp), wchar_t *);
+ CHECK_TYPE (wcspbrk (vp, cvp), wchar_t *);
+ CHECK_TYPE (wcspbrk (cvp, vp), const wchar_t *);
+ CHECK_TYPE (wcspbrk (cvp, cvp), const wchar_t *);
+ CHECK_TYPE (wcspbrk (wp, wp), wchar_t *);
+ CHECK_TYPE (wcspbrk (wp, cwp), wchar_t *);
+ CHECK_TYPE (wcspbrk (cwp, wp), const wchar_t *);
+ CHECK_TYPE (wcspbrk (cwp, cwp), const wchar_t *);
+ CHECK_TYPE (wcspbrk (0, wp), wchar_t *);
+ CHECK_TYPE (wcspbrk (0, cwp), wchar_t *);
+ CHECK_TYPE (wcspbrk ((void *) 0, wp), wchar_t *);
+ CHECK_TYPE (wcspbrk ((void *) 0, cwp), wchar_t *);
+ CHECK_TYPE ((wcspbrk) (cwp, cwp), wchar_t *);
+ CHECK_TYPE (wcsrchr (vp, wc), wchar_t *);
+ CHECK_TYPE (wcsrchr (cvp, wc), const wchar_t *);
+ CHECK_TYPE (wcsrchr (wp, wc), wchar_t *);
+ CHECK_TYPE (wcsrchr (cwp, wc), const wchar_t *);
+ CHECK_TYPE (wcsrchr (0, wc), wchar_t *);
+ CHECK_TYPE (wcsrchr ((void *) 0, wc), wchar_t *);
+ CHECK_TYPE ((wcsrchr) (cwp, wc), wchar_t *);
+ CHECK_TYPE (wcsstr (vp, vp), wchar_t *);
+ CHECK_TYPE (wcsstr (vp, cvp), wchar_t *);
+ CHECK_TYPE (wcsstr (cvp, vp), const wchar_t *);
+ CHECK_TYPE (wcsstr (cvp, cvp), const wchar_t *);
+ CHECK_TYPE (wcsstr (wp, wp), wchar_t *);
+ CHECK_TYPE (wcsstr (wp, cwp), wchar_t *);
+ CHECK_TYPE (wcsstr (cwp, wp), const wchar_t *);
+ CHECK_TYPE (wcsstr (cwp, cwp), const wchar_t *);
+ CHECK_TYPE (wcsstr (0, wp), wchar_t *);
+ CHECK_TYPE (wcsstr (0, cwp), wchar_t *);
+ CHECK_TYPE (wcsstr ((void *) 0, wp), wchar_t *);
+ CHECK_TYPE (wcsstr ((void *) 0, cwp), wchar_t *);
+ CHECK_TYPE ((wcsstr) (cwp, cwp), wchar_t *);
+ return 0;
+}
+
+#include <support/test-driver.c>
#else
extern wchar_t *wcschr (const wchar_t *__wcs, wchar_t __wc)
__THROW __attribute_pure__;
+# if __GLIBC_USE (ISOC23) && defined __glibc_const_generic && !defined _LIBC
+# define wcschr(WCS, WC) \
+ __glibc_const_generic (WCS, const wchar_t *, wcschr (WCS, WC))
+# endif
#endif
/* Find the last occurrence of WC in WCS. */
#ifdef __CORRECT_ISO_CPP_WCHAR_H_PROTO
#else
extern wchar_t *wcsrchr (const wchar_t *__wcs, wchar_t __wc)
__THROW __attribute_pure__;
+# if __GLIBC_USE (ISOC23) && defined __glibc_const_generic && !defined _LIBC
+# define wcsrchr(WCS, WC) \
+ __glibc_const_generic (WCS, const wchar_t *, wcsrchr (WCS, WC))
+# endif
#endif
#ifdef __USE_GNU
#else
extern wchar_t *wcspbrk (const wchar_t *__wcs, const wchar_t *__accept)
__THROW __attribute_pure__;
+# if __GLIBC_USE (ISOC23) && defined __glibc_const_generic && !defined _LIBC
+# define wcspbrk(WCS, ACCEPT) \
+ __glibc_const_generic (WCS, const wchar_t *, wcspbrk (WCS, ACCEPT))
+# endif
#endif
/* Find the first occurrence of NEEDLE in HAYSTACK. */
#ifdef __CORRECT_ISO_CPP_WCHAR_H_PROTO
#else
extern wchar_t *wcsstr (const wchar_t *__haystack, const wchar_t *__needle)
__THROW __attribute_pure__;
+# if __GLIBC_USE (ISOC23) && defined __glibc_const_generic && !defined _LIBC
+# define wcsstr(HAYSTACK, NEEDLE) \
+ __glibc_const_generic (HAYSTACK, const wchar_t *, \
+ wcsstr (HAYSTACK, NEEDLE))
+# endif
#endif
/* Divide WCS into tokens separated by characters in DELIM. */
#else
extern wchar_t *wmemchr (const wchar_t *__s, wchar_t __c, size_t __n)
__THROW __attribute_pure__;
+# if __GLIBC_USE (ISOC23) && defined __glibc_const_generic && !defined _LIBC
+# define wmemchr(S, C, N) \
+ __glibc_const_generic (S, const wchar_t *, wmemchr (S, C, N))
+# endif
#endif
/* Compare N wide characters of S1 and S2. */