1 //===----------------------------------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
11 // XFAIL: no-wide-characters
17 #include <type_traits>
19 #include "test_macros.h"
22 # error NULL not defined
26 # error WCHAR_MAX not defined
30 # error WCHAR_MIN not defined
34 # error WEOF not defined
37 int main(int, char**) {
38 std::mbstate_t mb
= {};
47 const wchar_t* cws
= 0;
50 ((void)mb
); // Prevent unused warning
51 ((void)s
); // Prevent unused warning
52 ((void)tm
); // Prevent unused warning
53 ((void)w
); // Prevent unused warning
54 ((void)fp
); // Prevent unused warning
55 ((void)va
); // Prevent unused warning
56 ((void)ns
); // Prevent unused warning
57 ((void)ws
); // Prevent unused warning
58 ((void)cws
); // Prevent unused warning
59 ((void)wsp
); // Prevent unused warning
61 ASSERT_SAME_TYPE(int, decltype(std::fwprintf(fp
, L
"")));
62 ASSERT_SAME_TYPE(int, decltype(std::fwscanf(fp
, L
"")));
63 ASSERT_SAME_TYPE(int, decltype(std::swprintf(ws
, s
, L
"")));
64 ASSERT_SAME_TYPE(int, decltype(std::swscanf(L
"", L
"")));
65 ASSERT_SAME_TYPE(int, decltype(std::vfwprintf(fp
, L
"", va
)));
66 ASSERT_SAME_TYPE(int, decltype(std::vfwscanf(fp
, L
"", va
)));
67 ASSERT_SAME_TYPE(int, decltype(std::vswprintf(ws
, s
, L
"", va
)));
68 ASSERT_SAME_TYPE(int, decltype(std::vswscanf(L
"", L
"", va
)));
69 ASSERT_SAME_TYPE(std::wint_t, decltype(std::fgetwc(fp
)));
70 ASSERT_SAME_TYPE(wchar_t*, decltype(std::fgetws(ws
, 0, fp
)));
71 ASSERT_SAME_TYPE(std::wint_t, decltype(std::fputwc(L
' ', fp
)));
72 ASSERT_SAME_TYPE(int, decltype(std::fputws(L
"", fp
)));
73 ASSERT_SAME_TYPE(int, decltype(std::fwide(fp
, 0)));
74 ASSERT_SAME_TYPE(std::wint_t, decltype(std::getwc(fp
)));
75 ASSERT_SAME_TYPE(std::wint_t, decltype(std::putwc(L
' ', fp
)));
76 ASSERT_SAME_TYPE(std::wint_t, decltype(std::ungetwc(L
' ', fp
)));
77 ASSERT_SAME_TYPE(double, decltype(std::wcstod(L
"", wsp
)));
78 ASSERT_SAME_TYPE(float, decltype(std::wcstof(L
"", wsp
)));
79 ASSERT_SAME_TYPE(long double, decltype(std::wcstold(L
"", wsp
)));
80 ASSERT_SAME_TYPE(long, decltype(std::wcstol(L
"", wsp
, 0)));
81 ASSERT_SAME_TYPE(long long, decltype(std::wcstoll(L
"", wsp
, 0)));
82 ASSERT_SAME_TYPE(unsigned long, decltype(std::wcstoul(L
"", wsp
, 0)));
83 ASSERT_SAME_TYPE(unsigned long long, decltype(std::wcstoull(L
"", wsp
, 0)));
84 ASSERT_SAME_TYPE(wchar_t*, decltype(std::wcscpy(ws
, L
"")));
85 ASSERT_SAME_TYPE(wchar_t*, decltype(std::wcsncpy(ws
, L
"", s
)));
86 ASSERT_SAME_TYPE(wchar_t*, decltype(std::wcscat(ws
, L
"")));
87 ASSERT_SAME_TYPE(wchar_t*, decltype(std::wcsncat(ws
, L
"", s
)));
88 ASSERT_SAME_TYPE(int, decltype(std::wcscmp(L
"", L
"")));
89 ASSERT_SAME_TYPE(int, decltype(std::wcscoll(L
"", L
"")));
90 ASSERT_SAME_TYPE(int, decltype(std::wcsncmp(L
"", L
"", s
)));
91 ASSERT_SAME_TYPE(std::size_t, decltype(std::wcsxfrm(ws
, L
"", s
)));
92 ASSERT_SAME_TYPE(wchar_t*, decltype(std::wcschr(ws
, L
' ')));
93 ASSERT_SAME_TYPE(const wchar_t*, decltype(std::wcschr(cws
, L
' ')));
94 ASSERT_SAME_TYPE(std::size_t, decltype(std::wcscspn(L
"", L
"")));
95 ASSERT_SAME_TYPE(std::size_t, decltype(std::wcslen(L
"")));
96 ASSERT_SAME_TYPE(wchar_t*, decltype(std::wcspbrk(ws
, L
"")));
97 ASSERT_SAME_TYPE(const wchar_t*, decltype(std::wcspbrk(cws
, L
"")));
98 ASSERT_SAME_TYPE(wchar_t*, decltype(std::wcsrchr(ws
, L
' ')));
99 ASSERT_SAME_TYPE(const wchar_t*, decltype(std::wcsrchr(cws
, L
' ')));
100 ASSERT_SAME_TYPE(std::size_t, decltype(std::wcsspn(L
"", L
"")));
101 ASSERT_SAME_TYPE(wchar_t*, decltype(std::wcsstr(ws
, L
"")));
102 ASSERT_SAME_TYPE(const wchar_t*, decltype(std::wcsstr(cws
, L
"")));
103 ASSERT_SAME_TYPE(wchar_t*, decltype(std::wcstok(ws
, L
"", wsp
)));
104 ASSERT_SAME_TYPE(wchar_t*, decltype(std::wmemchr(ws
, L
' ', s
)));
105 ASSERT_SAME_TYPE(const wchar_t*, decltype(std::wmemchr(cws
, L
' ', s
)));
106 ASSERT_SAME_TYPE(int, decltype(std::wmemcmp(L
"", L
"", s
)));
107 ASSERT_SAME_TYPE(wchar_t*, decltype(std::wmemcpy(ws
, L
"", s
)));
108 ASSERT_SAME_TYPE(wchar_t*, decltype(std::wmemmove(ws
, L
"", s
)));
109 ASSERT_SAME_TYPE(wchar_t*, decltype(std::wmemset(ws
, L
' ', s
)));
110 ASSERT_SAME_TYPE(std::size_t, decltype(std::wcsftime(ws
, s
, L
"", tm
)));
111 ASSERT_SAME_TYPE(wint_t, decltype(std::btowc(0)));
112 ASSERT_SAME_TYPE(int, decltype(std::wctob(w
)));
113 ASSERT_SAME_TYPE(int, decltype(std::mbsinit(&mb
)));
114 ASSERT_SAME_TYPE(std::size_t, decltype(std::mbrlen("", s
, &mb
)));
115 ASSERT_SAME_TYPE(std::size_t, decltype(std::mbrtowc(ws
, "", s
, &mb
)));
116 ASSERT_SAME_TYPE(std::size_t, decltype(std::wcrtomb(ns
, L
' ', &mb
)));
117 ASSERT_SAME_TYPE(std::size_t, decltype(std::mbsrtowcs(ws
, (const char**)0, s
, &mb
)));
118 ASSERT_SAME_TYPE(std::size_t, decltype(std::wcsrtombs(ns
, (const wchar_t**)0, s
, &mb
)));
120 ASSERT_SAME_TYPE(std::wint_t, decltype(std::getwchar()));
121 ASSERT_SAME_TYPE(int, decltype(std::vwscanf(L
"", va
)));
122 ASSERT_SAME_TYPE(int, decltype(std::wscanf(L
"")));
124 ASSERT_SAME_TYPE(std::wint_t, decltype(std::putwchar(L
' ')));
125 ASSERT_SAME_TYPE(int, decltype(std::vwprintf(L
"", va
)));
126 ASSERT_SAME_TYPE(int, decltype(std::wprintf(L
"")));