@@ -21,6 +21,7 @@ extern "C" {
2121 extern void *memchr (const void *s, int c, size_t n);
2222 extern char *strchr (const char *s, int c);
2323 extern wchar_t *wmemchr (const wchar_t *s, wchar_t c, size_t n);
24+ extern wchar_t *wcschr (const wchar_t *s, wchar_t c);
2425}
2526
2627namespace strcmp {
@@ -1511,4 +1512,24 @@ namespace WMemChr {
15111512
15121513 constexpr wchar_t kStr2 [] = {L' f' , L' o' , L' \xff ff' , L' o' };
15131514 static_assert (__builtin_wmemchr(kStr2 , L' \xff ff' , 4 ) == kStr2 + 2 );
1515+
1516+
1517+ static_assert (__builtin_wcschr(kStr , L' a' ) == kStr );
1518+ static_assert (__builtin_wcschr(kStr , L' b' ) == kStr + 1 );
1519+ static_assert (__builtin_wcschr(kStr , L' c' ) == kStr + 2 );
1520+ static_assert (__builtin_wcschr(kStr , L' d' ) == nullptr );
1521+ static_assert (__builtin_wcschr(kStr , L' e' ) == nullptr );
1522+ static_assert (__builtin_wcschr(kStr , L' \0 ' ) == kStr + 5 );
1523+ static_assert (__builtin_wcschr(kStr , L' a' + 256 ) == nullptr );
1524+ static_assert (__builtin_wcschr(kStr , L' a' - 256 ) == nullptr );
1525+ static_assert (__builtin_wcschr(kStr , L' \xff ff' ) == kStr + 4 );
1526+ static_assert (__builtin_wcschr(kFoo , L' o' ) == kFoo + 1 );
1527+ static_assert (__builtin_wcschr(kFoo , L' x' ) == nullptr ); // both-error {{not an integral constant}} \
1528+ // both-note {{dereferenced one-past-the-end}}
1529+ static_assert (__builtin_wcschr(nullptr , L' x' ) == nullptr ); // both-error {{not an integral constant}} \
1530+ // both-note {{dereferenced null}}
1531+
1532+
1533+ constexpr bool c = !wcschr(L" hello" , L' h' ); // both-error {{constant expression}} \
1534+ // both-note {{non-constexpr function 'wcschr' cannot be used in a constant expression}}
15141535}
0 commit comments