| 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 | #include <iostream> |
| 10 | #include <cassert> |
| 11 | |
| 12 | #include "test_macros.h" |
| 13 | |
| 14 | // Test to make sure that the streams only get initialized once |
| 15 | // Taken from https://llvm.org/PR43300 |
| 16 | |
| 17 | // This test requires the fix for PR43300 (7b81a13bfcd1). |
| 18 | // XFAIL: using-built-library-before-llvm-9 |
| 19 | |
| 20 | int main(int, char**) |
| 21 | { |
| 22 | |
| 23 | std::cout << "Hello!"; |
| 24 | std::ios_base::fmtflags stock_flags = std::cout.flags(); |
| 25 | |
| 26 | std::cout << std::boolalpha << true; |
| 27 | std::ios_base::fmtflags ba_flags = std::cout.flags(); |
| 28 | assert(stock_flags != ba_flags); |
| 29 | |
| 30 | std::ios_base::Init init_streams; |
| 31 | std::ios_base::fmtflags after_init = std::cout.flags(); |
| 32 | assert(after_init == ba_flags); |
| 33 | |
| 34 | return 0; |
| 35 | } |
| 36 |
