• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 is a single expression. This is useful so we can use
10 // it in places that require an expression, such as in a constructor initializer list.
11 
12 // RUN: %{build} -Wno-macro-redefined -D_LIBCPP_ENABLE_ASSERTIONS=1
13 // RUN: %{run}
14 
15 // RUN: %{build} -Wno-macro-redefined -D_LIBCPP_ENABLE_ASSERTIONS=0
16 // RUN: %{run}
17 
18 // RUN: %{build} -Wno-macro-redefined -D_LIBCPP_ENABLE_ASSERTIONS=0 -D_LIBCPP_ASSERTIONS_DISABLE_ASSUME
19 // RUN: %{run}
20 
21 #include <__assert>
22 #include <cassert>
23 
f()24 void f() {
25   int i = (_LIBCPP_ASSERT(true, "message"), 3);
26   assert(i == 3);
27   return _LIBCPP_ASSERT(true, "message");
28 }
29 
main(int,char **)30 int main(int, char**) {
31   f();
32   return 0;
33 }
34