xref: /llvm-project/libcxx/test/std/depr/depr.c.headers/string_h.pass.cpp (revision 9178fb73e13cb5b486277deeafc69740f8c04c8a)
1 //===----------------------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 // <string.h>
10 
11 #include <string.h>
12 #include <type_traits>
13 
14 #include "test_macros.h"
15 
16 #ifndef NULL
17 #error NULL not defined
18 #endif
19 
20 int main(int, char**)
21 {
22     size_t s = 0;
23     void* vp = 0;
24     const void* vpc = 0;
25     char* cp = 0;
26     const char* cpc = 0;
27     ASSERT_SAME_TYPE(void*,         decltype(memcpy(vp, vpc, s)));
28     ASSERT_SAME_TYPE(void*,         decltype(memmove(vp, vpc, s)));
29     ASSERT_SAME_TYPE(char*,         decltype(strcpy(cp, cpc)));
30     ASSERT_SAME_TYPE(char*,         decltype(strncpy(cp, cpc, s)));
31     ASSERT_SAME_TYPE(char*,         decltype(strcat(cp, cpc)));
32     ASSERT_SAME_TYPE(char*,         decltype(strncat(cp, cpc, s)));
33     ASSERT_SAME_TYPE(int,           decltype(memcmp(vpc, vpc, s)));
34     ASSERT_SAME_TYPE(int,           decltype(strcmp(cpc, cpc)));
35     ASSERT_SAME_TYPE(int,           decltype(strncmp(cpc, cpc, s)));
36     ASSERT_SAME_TYPE(int,           decltype(strcoll(cpc, cpc)));
37     ASSERT_SAME_TYPE(size_t,        decltype(strxfrm(cp, cpc, s)));
38     ASSERT_SAME_TYPE(void*,         decltype(memchr(vp, 0, s)));
39     ASSERT_SAME_TYPE(const void*,   decltype(memchr(vpc, 0, s)));
40     ASSERT_SAME_TYPE(char*,         decltype(strchr(cp, 0)));
41     ASSERT_SAME_TYPE(const char*,   decltype(strchr(cpc, 0)));
42     ASSERT_SAME_TYPE(size_t,        decltype(strcspn(cpc, cpc)));
43     ASSERT_SAME_TYPE(char*,         decltype(strpbrk(cp, cpc)));
44     ASSERT_SAME_TYPE(const char*,   decltype(strpbrk(cpc, cpc)));
45     ASSERT_SAME_TYPE(char*,         decltype(strrchr(cp, 0)));
46     ASSERT_SAME_TYPE(const char*,   decltype(strrchr(cpc, 0)));
47     ASSERT_SAME_TYPE(size_t,        decltype(strspn(cpc, cpc)));
48     ASSERT_SAME_TYPE(char*,         decltype(strstr(cp, cpc)));
49     ASSERT_SAME_TYPE(const char*,   decltype(strstr(cpc, cpc)));
50 #ifndef _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS
51     ASSERT_SAME_TYPE(char*,         decltype(strtok(cp, cpc)));
52 #endif
53     ASSERT_SAME_TYPE(void*,         decltype(memset(vp, 0, s)));
54     ASSERT_SAME_TYPE(char*,         decltype(strerror(0)));
55     ASSERT_SAME_TYPE(size_t,        decltype(strlen(cpc)));
56 
57     return 0;
58 }
59