File tree Expand file tree Collapse file tree 2 files changed +68
-0
lines changed
gcc/testsuite/g++.dg/contracts/cpp26 Expand file tree Collapse file tree 2 files changed +68
-0
lines changed Original file line number Diff line number Diff line change
1
+ // { dg-do compile }
2
+ // { dg-options "-std=c++23 -fcontracts -fcontracts-nonattr -fcontracts-nonattr-inheritance-mode=P2900R13 " }
3
+
4
+ struct NTClass {
5
+ //TODO, make non trivial when https://github.com/NinaRanns/gcc/issues/21 is solved
6
+ // NTClass(){};
7
+ // ~NTClass(){};
8
+ };
9
+
10
+ template < typename ... ARGS >
11
+ bool check (ARGS ... args ){ return true;}
12
+
13
+
14
+ struct Base
15
+ {
16
+ virtual void f (const NTClass i );
17
+
18
+ } ;
19
+
20
+ struct Derived : Base
21
+ {
22
+ virtual void f (const NTClass i ) post (check (i ));
23
+ };
24
+
25
+ struct DerivedV : virtual Base
26
+ {
27
+ virtual void f (const NTClass i ) post (check (i ));
28
+ };
29
+
30
+ void
31
+ Derived ::f (NTClass i ){} // { dg-error "used in a postcondition must be const" }
32
+
33
+ void
34
+ DerivedV ::f (NTClass i ){} // { dg-error "used in a postcondition must be const" }
Original file line number Diff line number Diff line change
1
+ // { dg-do compile }
2
+ // { dg-options "-std=c++23 -fcontracts -fcontracts-nonattr -fcontracts-nonattr-inheritance-mode=P3653 " }
3
+
4
+ struct NTClass {
5
+ //TODO, make non trivial when https://github.com/NinaRanns/gcc/issues/21 is solved
6
+ // NTClass(){};
7
+ // ~NTClass(){};
8
+ };
9
+
10
+ template < typename ... ARGS >
11
+ bool check (ARGS ... args ){ return true;}
12
+
13
+
14
+ struct Base
15
+ {
16
+ virtual void f (const NTClass i );
17
+
18
+ } ;
19
+
20
+ struct Derived : Base
21
+ {
22
+ virtual void f (const NTClass i ) post (check (i ));
23
+ };
24
+
25
+ struct DerivedV : virtual Base
26
+ {
27
+ virtual void f (const NTClass i ) post (check (i ));
28
+ };
29
+
30
+ void
31
+ Derived ::f (NTClass i ){} // { dg-error "used in a postcondition must be const" }
32
+
33
+ void
34
+ DerivedV ::f (NTClass i ){} // { dg-error "used in a postcondition must be const" }
You can’t perform that action at this time.
0 commit comments