Debian Codegraph @

gcc/testsuite/g++.dg/modules/contracts-4_a.C

raw
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 // { dg-skip-if "requires hosted libstdc++ for cstdio" { ! hostedlib } }
6 module;
7 #include <cstdio>
8 #include <experimental/contract>
9 export module foo;
10 // { dg-module-cmi foo }
11
12 export int violation_count{0};
13 export extern "C++" void handle_contract_violation(const std::experimental::contract_violation &violation)
14 {
15 violation_count++;
16 printf("violation_count: %d\n", violation_count);
17 }
18
19 export template<typename T>
20 T fn_t(T t)
21 [[ pre: t > 0 ]]
22 [[ pre audit %custom: t > 0 ]]
23 {
24 printf("%s(%d)\n", __FUNCTION__, t);
25 return t;
26 }
27
28 export int fn_int(int n);
29