gcc/testsuite/g++.dg/modules/contracts-5_b.C
raw| 1 | // PR c++/108205 |
| 2 | // { dg-module-do run } |
| 3 | // { dg-additional-options "-fmodules -fcontracts -fcontract-continuation-mode=on" } |
| 4 | |
| 5 | #include <experimental/contract> |
| 6 | import test; |
| 7 | |
| 8 | bool saw_violation = false; |
| 9 | void handle_contract_violation(const std::experimental::contract_violation& v) { |
| 10 | saw_violation = true; |
| 11 | } |
| 12 | |
| 13 | int main() { |
| 14 | foo(10); |
| 15 | if (saw_violation) |
| 16 | __builtin_abort(); |
| 17 | foo(0); |
| 18 | if (!saw_violation) |
| 19 | __builtin_abort(); |
| 20 | } |