Debian Codegraph @

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

raw
1 // { dg-do compile }
2 // { dg-options "-std=c++2a -fcontracts" }
3
4 struct S
5 {
6 S() [[post: n == 0]]
7 : n(0)
8 { }
9
10 ~S() [[post: true]]
11 { }
12
13 int f1()
14 [[post r: n == r]]
15 {
16 return n;
17 }
18
19 int f2()
20 [[post r: r == x]] // { dg-error "not declared" }
21 {
22 return n;
23 }
24
25 void f3()
26 [[post r: n]] // { dg-error "does not return a value" }
27 {
28 }
29
30 int n = 0;
31 };
32
33 int main()
34 {
35 // f1(0);
36 }