| 1 |
// { dg-do compile } |
| 2 |
// { dg-options "-std=c++2a -fcontracts -fcontract-continuation-mode=on" } |
| 3 |
|
| 4 |
struct BaseA { |
| 5 |
virtual int fun(int n) [[ pre: n > 0 ]] { return -n; } |
| 6 |
}; |
| 7 |
|
| 8 |
struct BaseB { |
| 9 |
virtual int fun(int n) [[ pre: n < 0 ]] { return -n; } |
| 10 |
}; |
| 11 |
|
| 12 |
struct Child1 : public BaseA, BaseB { |
| 13 |
int fun(int n) [[ pre: n > 0 ]] { return -n; } // { dg-error "mismatched" } |
| 14 |
}; |
| 15 |
|
| 16 |
struct Child2 : public BaseA, BaseB { |
| 17 |
int fun(int n) [[ pre: n < 0 ]] { return -n; } // { dg-error "mismatched" } |
| 18 |
}; |
| 19 |
|
| 20 |
struct Child3 : public BaseA, BaseB { |
| 21 |
int fun(int n) { return -n; } |
| 22 |
}; |
| 23 |
|
| 24 |
struct Child4 : public BaseA { |
| 25 |
int fun(int n); |
| 26 |
}; |
| 27 |
|
| 28 |
int Child4::fun(int n) |
| 29 |
[[ pre: n != 0 ]] // { dg-error "mismatched" } |
| 30 |
{ |
| 31 |
return -n; |
| 32 |
} |
| 33 |
|