• 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 // Test that _LIBCPP_ASSERT doesn't do anything when assertions are disabled.
10 // We need to use -Wno-macro-redefined because the test suite defines
11 // _LIBCPP_ENABLE_ASSERTIONS=1 under some configurations.
12 
13 // ADDITIONAL_COMPILE_FLAGS: -Wno-macro-redefined -D_LIBCPP_ENABLE_ASSERTIONS=0
14 
15 #include <cassert>
16 
17 bool executed_condition = false;
f()18 bool f() { executed_condition = true; return false; }
19 
main(int,char **)20 int main(int, char**) {
21   _LIBCPP_ASSERT(f(), "message"); // should not execute anything
22   assert(!executed_condition); // really make sure we did not execute anything at all
23   return 0;
24 }
25