Debian Codegraph @

gcc/testsuite/g++.dg/contracts/contracts19.C

raw
1 // check that a valid program using assertions compiles and runs
2 // ensure an axiom with a failing predicate doesn't prevent a successful run
3 // (axiom level contracts are never checked at runtime)
4 // { dg-do run }
5 // { dg-options "-std=c++2a -fcontracts -fcontract-role=custom:maybe,maybe,ignore" }
6
7 int main()
8 {
9 int x = 10;
10 [[assert axiom: x < 0]];
11 [[assert %custom: x < 0]];
12 [[assert audit %custom: x < 1]];
13 [[assert axiom %custom: x < 1]];
14 return 0;
15 }
16
17 // { dg-skip-if "requires hosted libstdc++ for stdc++exp" { ! hostedlib } }
18 // { dg-output "contract violation in function main at .*.C:11: .*(\n|\r\n|\r)" }
19 // { dg-output "contract violation in function main at .*.C:12: .*(\n|\r\n|\r)" }
20