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 // Make sure that `_LIBCPP_ASSERT` and `_LIBCPP_ASSUME` are each a single expression.
10 // This is useful so we can use them in places that require an expression, such as
11 // in a constructor initializer list.
12
13 #include <__assert>
14 #include <cassert>
15
f()16 void f() {
17 int i = (_LIBCPP_ASSERT(true, "message"), 3);
18 assert(i == 3);
19 return _LIBCPP_ASSERT(true, "message");
20 }
21
g()22 void g() {
23 int i = (_LIBCPP_ASSUME(true), 3);
24 assert(i == 3);
25 return _LIBCPP_ASSUME(true);
26 }
27
main(int,char **)28 int main(int, char**) {
29 f();
30 g();
31 return 0;
32 }
33