1 /* REQUIRED_ARGS: -preview=nosharedaccess
4 pure nothrow @nogc ref @safe shared(C1)(return ref shared(C1) c)
5 pure nothrow @nogc ref @safe shared(int)(return ref shared(C3) c)
8 ref shared(int) f(return shared ref int y
)
13 // https://issues.dlang.org/show_bug.cgi?id=20908
16 // shared locals (or struct members) should be able to be initialised:
21 static shared(int) val
;
23 // return by reference
27 ref shared(int) fun2()
29 static shared(int)* val
;
31 // transfer pointer to reference
35 ref shared(int) fun3()
37 static shared(int)*** val
;
39 // Multiple indirections
44 // Simple tests for `DotVarExp`
45 // A `DotVarExp` is `a.b`. If `a` is a `shared ref`,
46 // it is of type `shared(T)*` (as opposed to `shared(T*)`).
47 // We should allow arbitrarily nested `DotVarExp` as long
48 // as no shared memory is read, as in the case above
49 // (we're just offsetting a pointer).
66 ref shared(int) test_dotvarexp_1(return ref shared C1 c
)
71 shared(int)* test_dotvarexp_2(return ref shared C1 c
)
76 shared(C2
)* test_dotvarexp_3(return ref shared C3 c
)
81 shared(C2
)* test_dotvarexp_4(return ref shared C3 c
)
86 ref shared(int) test_dotvarexp_5(return shared ref C3 c
)
91 ref shared(int) test_dotvarexp_5(return ref shared(C3
)[] c
)
93 return c
[0].c1
.c1
.value
;
96 // Test `auto` inference
97 auto ref test_inference_1(return ref shared C1 c
)
102 pragma(msg
, typeof(test_inference_1
));
104 auto ref test_inference_2(return ref shared C3 c
)
106 return c
.c2
.c1
.value
;
109 pragma(msg
, typeof(test_inference_2
));
111 // https://issues.dlang.org/show_bug.cgi?id=21793
123 ch
= shared Child(i
);