Debian Codegraph @

gcc/testsuite/g++.dg/contracts/contracts-ignore2.C

raw
1 // baseline for testing assert contracts being turned into compile time
2 // assumptions; see contracts-assume2 for the assumed case
3 // { dg-do run }
4 // { dg-options "-std=c++2a -fcontracts" }
5 // { dg-skip-if "requires hosted libstdc++ for cstdio" { ! hostedlib } }
6 #include <cstdio>
7
8 int fun(int x) {
9 [[assert audit: x > 0]];
10 if(x <= 0)
11 {
12 printf("%d: test x<=0 opt out\n", x);
13 return -1;
14 }
15 else
16 {
17 printf("%d: test x>0\n", x);
18 return 0;
19 }
20 }
21
22 int main(int, char**) {
23 volatile int x = -1;
24 return fun(x);
25 }
26
27 // { dg-shouldfail "" }