Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / libcxx / test / std / language.support / support.runtime / csetjmp.pass.cpp
blobd6d32c371b9e5caaeacce49c4fd2a47634b7bdb3
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 // test <csetjmp>
11 #include <csetjmp>
12 #include <cassert>
13 #include <type_traits>
15 int main(int, char**) {
16 std::jmp_buf jb;
18 switch (setjmp(jb)) {
19 // First time we set the buffer, the function should return 0
20 case 0:
21 break;
23 // If it returned 42, then we're coming from the std::longjmp call below
24 case 42:
25 return 0;
27 // Otherwise, something is wrong
28 default:
29 return 1;
32 std::longjmp(jb, 42);
33 static_assert(std::is_same<decltype(std::longjmp(jb, 0)), void>::value, "");
35 return 1;