Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / libcxx / test / std / input.output / iostream.objects / wide.stream.objects / wcerr-imbue.sh.cpp
blobec4c8a009ba0c09505604e1ba4d9461f74346777
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 //===----------------------------------------------------------------------===//
9 // <iostream>
11 // wostream wcerr;
13 // UNSUPPORTED: no-wide-characters
15 // RUN: %{build}
16 // RUN: %{exec} %t.exe 2> %t.actual
17 // RUN: echo -n zzzz > %t.expected
18 // RUN: diff %t.expected %t.actual
20 #include <iostream>
22 struct custom_codecvt : std::codecvt<wchar_t, char, std::mbstate_t> {
23 using base = std::codecvt<wchar_t, char, std::mbstate_t>;
24 protected:
25 result do_out(std::mbstate_t&, const wchar_t *from, const wchar_t *from_end,
26 const wchar_t *&from_next, char *to, char *to_end, char *&to_next) const {
27 while (from != from_end && to != to_end) {
28 ++from;
29 *to++ = 'z';
31 from_next = from;
32 to_next = to;
33 return ok;
37 int main(int, char**) {
38 std::locale loc(std::locale::classic(), new custom_codecvt);
39 std::wcerr.imbue(loc);
40 std::wcerr << L"1234";
41 return 0;