| 1 |
// { dg-do compile } |
| 2 |
// { dg-options "-Wunused-value" } |
| 3 |
|
| 4 |
@safe pure nothrow T t1(T)(T x) |
| 5 |
{ |
| 6 |
return x * x; |
| 7 |
} |
| 8 |
|
| 9 |
nothrow pure int f1(immutable(int)[] a) |
| 10 |
{ |
| 11 |
return 0; |
| 12 |
} |
| 13 |
|
| 14 |
nothrow pure int f2(immutable(int)* p) |
| 15 |
{ |
| 16 |
return 0; |
| 17 |
} |
| 18 |
|
| 19 |
void test() |
| 20 |
{ |
| 21 |
int x = 3; |
| 22 |
t1(x); // { dg-warning "without side effects discards return value" } |
| 23 |
|
| 24 |
auto fp = &t1!int; |
| 25 |
fp(x); // { dg-warning "without side effects discards return value" } |
| 26 |
|
| 27 |
f1([]); // { dg-warning "without side effects discards return value" } |
| 28 |
f2(null); // { dg-warning "without side effects discards return value" } |
| 29 |
} |