brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1011 B · e79dee9 Raw
31 lines · cpp
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-exception6//7//===----------------------------------------------------------------------===//8 9// This test checks that if no hardening mode is defined (i.e., in the unchecked mode), by default assertions aren't10// triggered.11 12// REQUIRES: libcpp-hardening-mode=none13 14#include <__cxx03/__assert>15#include <cassert>16 17bool executed_condition = false;18bool f() {19  executed_condition = true;20  return false;21}22 23int main(int, char**) {24  _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(true, "Should not fire");25  _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(false, "Also should not fire");26  _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(f(), "Should not execute anything");27  assert(!executed_condition); // Really make sure we did not execute anything.28 29  return 0;30}31