gcc/testsuite/g++.dg/contracts/contracts20.C
raw| 1 | // test that contract attributes cause errors pre-c++2a |
| 2 | // { dg-do compile { target c++17_only } } |
| 3 | |
| 4 | int fun(int a) |
| 5 | [[ pre: a > 0 ]] // { dg-error "contracts are only available with .-fcontracts." } |
| 6 | [[ post r: r < 0 ]] // { dg-error "contracts are only available with .-fcontracts." } |
| 7 | { |
| 8 | [[ assert: a != 0 ]]; // { dg-error "contracts are only available with .-fcontracts." } |
| 9 | return -a; |
| 10 | } |
| 11 |