c++: Implement P2615 'Meaningful Exports' [PR107688]
[official-gcc.git] / gcc / testsuite / g++.dg / modules / contracts-4_a.C
bloba135f50fb7d87ad0d6f4ea073415a27557ccc5c9
1 // Test that template contracts are not reintpreted when the reinterpret
2 // contracts flag is not set, regardless of the current TU's contract
3 // configuration.
4 // { dg-additional-options "-fmodules-ts -fcontracts -fcontract-role=default:maybe,maybe,ignore" }
5 module;
6 #include <cstdio>
7 #include <experimental/contract>
8 export module foo;
9 // { dg-module-cmi foo }
11 export int violation_count{0};
12 export extern "C++" void handle_contract_violation(const std::experimental::contract_violation &violation)
14   violation_count++;
15   printf("violation_count: %d\n", violation_count);
18 export template<typename T>
19 T fn_t(T t)
20   [[ pre: t > 0 ]]
21   [[ pre audit %custom: t > 0 ]]
23   printf("%s(%d)\n", __FUNCTION__, t);
24   return t;
27 export int fn_int(int n);