| 1 |
// { dg-module-do run } |
| 2 |
// { dg-additional-options "-fmodules-ts -fcontracts -fcontract-role=default:ignore,ignore,ignore" } |
| 3 |
// { dg-skip-if "requires hosted libstdc++ for cstdio" { ! hostedlib } } |
| 4 |
|
| 5 |
#include <cstdio> |
| 6 |
import foo; |
| 7 |
|
| 8 |
template<typename T> |
| 9 |
bool bar_fn_pre(T n) { printf("bar fn pre(%d)\n", n); return true; } |
| 10 |
|
| 11 |
template<typename T> |
| 12 |
T bar_fn(T n) |
| 13 |
[[ pre: bar_fn_pre(n) && n > 0 ]] |
| 14 |
{ |
| 15 |
printf("%s(%d)\n", __FUNCTION__, n); |
| 16 |
return n; |
| 17 |
} |
| 18 |
|
| 19 |
int main(int, char**) |
| 20 |
{ |
| 21 |
nontemplate(5); |
| 22 |
nontemplate(-5); |
| 23 |
fn(5); |
| 24 |
fn(-5); |
| 25 |
fn(5.3); |
| 26 |
fn(-5.3); |
| 27 |
void_fn(5); |
| 28 |
void_fn(-5); |
| 29 |
bar_fn(5); |
| 30 |
bar_fn(-5); |
| 31 |
return violation_count == 7 ? 0 : -1; |
| 32 |
} |
| 33 |
|