@@ -21,6 +21,7 @@ extern "C" {
21
21
extern void *memchr (const void *s, int c, size_t n);
22
22
extern char *strchr (const char *s, int c);
23
23
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);
24
25
}
25
26
26
27
namespace strcmp {
@@ -1511,4 +1512,24 @@ namespace WMemChr {
1511
1512
1512
1513
constexpr wchar_t kStr2 [] = {L' f' , L' o' , L' \xff ff' , L' o' };
1513
1514
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}}
1514
1535
}
0 commit comments