aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/modules/contracts-4_a.C
blob: f269e6c207826efe39a8e56b83dc67be3aa7c27f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// Test that template contracts are not reintpreted when the reinterpret
// contracts flag is not set, regardless of the current TU's contract
// configuration.
// { dg-additional-options "-fmodules-ts -fcontracts -fcontract-role=default:maybe,maybe,ignore" }
module;
#include <cstdio>
#include <experimental/contract>
export module foo;
// { dg-module-cmi foo }

export int violation_count{0};
extern "C++" export void handle_contract_violation(const std::experimental::contract_violation &violation)
{
  violation_count++;
  printf("violation_count: %d\n", violation_count);
}

export template<typename T>
T fn_t(T t)
  [[ pre: t > 0 ]]
  [[ pre audit %custom: t > 0 ]]
{
  printf("%s(%d)\n", __FUNCTION__, t);
  return t;
}

export int fn_int(int n);