summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gdc.test/fail_compilation/test18484.d
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/gdc.test/fail_compilation/test18484.d')
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/test18484.d26
1 files changed, 26 insertions, 0 deletions
diff --git a/gcc/testsuite/gdc.test/fail_compilation/test18484.d b/gcc/testsuite/gdc.test/fail_compilation/test18484.d
new file mode 100644
index 00000000000..678609b770d
--- /dev/null
+++ b/gcc/testsuite/gdc.test/fail_compilation/test18484.d
@@ -0,0 +1,26 @@
+/* REQUIRED_ARGS: -preview=dip1000
+TEST_OUTPUT:
+---
+fail_compilation/test18484.d(19): Error: returning `x.bar()` escapes a reference to local variable `x`
+fail_compilation/test18484.d(24): Error: escaping reference to stack allocated value returned by `S(0)`
+---
+*/
+
+// https://issues.dlang.org/show_bug.cgi?id=18484
+
+struct S
+{
+ int* bar() return;
+ int i;
+}
+
+int* test1()
+{
+ auto x = S(); return x.bar(); // error
+}
+
+int* test2()
+{
+ return S().bar(); // error
+}
+