gcc/testsuite/gdc.test/fail_compilation/test22910.d
raw| 1 | /* REQUIRED_ARGS: -preview=dip1000 |
| 2 | TEST_OUTPUT: |
| 3 | --- |
| 4 | fail_compilation/test22910.d(17): Error: escaping a reference to parameter `this` by returning `&this.val` is not allowed in a `@safe` function |
| 5 | fail_compilation/test22910.d(15): perhaps change the `return scope` into `scope return` |
| 6 | --- |
| 7 | */ |
| 8 | @safe: |
| 9 | |
| 10 | struct S |
| 11 | { |
| 12 | int val; |
| 13 | int* ptr; |
| 14 | |
| 15 | int* retScope() return scope |
| 16 | { |
| 17 | return &this.val; |
| 18 | } |
| 19 | } |