summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gdc.test/fail_compilation/diag14145.d
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/gdc.test/fail_compilation/diag14145.d')
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/diag14145.d38
1 files changed, 38 insertions, 0 deletions
diff --git a/gcc/testsuite/gdc.test/fail_compilation/diag14145.d b/gcc/testsuite/gdc.test/fail_compilation/diag14145.d
new file mode 100644
index 00000000000..d292f768f75
--- /dev/null
+++ b/gcc/testsuite/gdc.test/fail_compilation/diag14145.d
@@ -0,0 +1,38 @@
+/*
+TEST_OUTPUT:
+---
+fail_compilation/diag14145.d(15): Error: no property `i` for type `diag14145.main.Capture!(i)`
+fail_compilation/diag14145.d(15): potentially malformed `opDispatch`. Use an explicit instantiation to get a better error message
+fail_compilation/diag14145.d(34): Error: expression `*this.ptr` of type `shared(int)` is not implicitly convertible to return type `ref int`
+fail_compilation/diag14145.d(16): Error: template instance `diag14145.main.Capture!(i).Capture.opDispatch!"i"` error instantiating
+---
+*/
+
+int main()
+{
+ int i;
+ auto _ = capture!i;
+ _.i;
+ _.opDispatch!"i";
+ return 0;
+}
+
+auto capture(alias c)()
+{
+ return Capture!c(c);
+}
+
+struct Capture(alias c)
+{
+ shared typeof(c)* ptr;
+ this(ref typeof(c) _c)
+ {
+ ptr = cast(shared)&c;
+ }
+ ref shared typeof(c) opDispatch(string s)()
+ {
+ return *ptr;
+ }
+}
+
+