| 1 |
/* |
| 2 |
TEST_OUTPUT: |
| 3 |
--- |
| 4 |
fail_compilation/diag10319.d(30): Error: `pure` function `D main` cannot call impure function `diag10319.foo` |
| 5 |
fail_compilation/diag10319.d(30): Error: `@safe` function `D main` cannot call `@system` function `diag10319.foo` |
| 6 |
fail_compilation/diag10319.d(19): `diag10319.foo` is declared here |
| 7 |
fail_compilation/diag10319.d(31): Error: `pure` function `D main` cannot call impure function `diag10319.bar!int.bar` |
| 8 |
fail_compilation/diag10319.d(23): and accessing mutable static data `g` makes it fail to infer `pure` |
| 9 |
fail_compilation/diag10319.d(31): Error: `@safe` function `D main` cannot call `@system` function `diag10319.bar!int.bar` |
| 10 |
fail_compilation/diag10319.d(24): and taking the address of stack-allocated local variable `x` makes it fail to infer `@safe` |
| 11 |
fail_compilation/diag10319.d(21): `diag10319.bar!int.bar` is declared here |
| 12 |
fail_compilation/diag10319.d(30): Error: function `diag10319.foo` is not `nothrow` |
| 13 |
fail_compilation/diag10319.d(31): Error: function `diag10319.bar!int.bar` is not `nothrow` |
| 14 |
fail_compilation/diag10319.d(25): and `object.Exception` being thrown but not caught makes it fail to infer `nothrow` |
| 15 |
fail_compilation/diag10319.d(28): Error: function `D main` may throw but is marked as `nothrow` |
| 16 |
--- |
| 17 |
*/ |
| 18 |
|
| 19 |
void foo() {} |
| 20 |
|
| 21 |
void bar(T)() |
| 22 |
{ |
| 23 |
static int g; g = 10; // impure |
| 24 |
int x; auto p = &x; // system |
| 25 |
throw new Exception(""); // may throw |
| 26 |
} |
| 27 |
|
| 28 |
@safe pure nothrow void main() // L23 |
| 29 |
{ |
| 30 |
foo(); // L25 |
| 31 |
bar!int(); // L26 |
| 32 |
} |