diff options
Diffstat (limited to 'gcc/testsuite/gdc.test/fail_compilation/test19097.d')
-rw-r--r-- | gcc/testsuite/gdc.test/fail_compilation/test19097.d | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/gcc/testsuite/gdc.test/fail_compilation/test19097.d b/gcc/testsuite/gdc.test/fail_compilation/test19097.d new file mode 100644 index 00000000000..b5560f0b27b --- /dev/null +++ b/gcc/testsuite/gdc.test/fail_compilation/test19097.d @@ -0,0 +1,56 @@ +/* REQUIRED_ARGS: -preview=dip1000 + * TEST_OUTPUT: +--- +fail_compilation/test19097.d(35): Error: scope variable `s` may not be returned +--- + */ + +// https://issues.dlang.org/show_bug.cgi?id=19097 + +@safe: + +void betty(ref scope int* r, return scope int* p) +{ + r = p; +} + +void freddy(out scope int* r, return scope int* p) +{ + r = p; +} + +struct S +{ + int* a; + this(return scope int* b) scope { a = b; } + + int* c; + void mem(return scope int* d) scope { c = d; } +} + +S thorin() +{ + int i; + S s = S(&i); // should infer scope for s + return s; // so this should error +} + +/************************/ + +struct S2(T) +{ + int* p; + + void silent(lazy void dg); + + void foo() + { + char[] name; + silent(name = parseType()); + } + + char[] parseType(char[] name = null); +} + +S2!int s2; + |