d: Merge upstream dmd, druntime 4c18eed967, phobos d945686a4.
[official-gcc.git] / gcc / testsuite / gdc.test / fail_compilation / b20011.d
blob7baad47f378ad2f2fa023caea602d8f897251b84
1 /*
2 TEST_OUTPUT:
3 ---
4 fail_compilation/b20011.d(25): Error: `S1(cast(ubyte)0u).member` is not an lvalue and cannot be modified
5 fail_compilation/b20011.d(28): Error: `S2(null).member` is not an lvalue and cannot be modified
6 fail_compilation/b20011.d(29): Error: `S2(null).member` is not an lvalue and cannot be modified
7 fail_compilation/b20011.d(32): Error: `U1(cast(ubyte)0u, ).m2` is not an lvalue and cannot be modified
8 fail_compilation/b20011.d(37): Error: function `b20011.main.assignableByRef(ref ubyte p)` is not callable using argument types `(ubyte)`
9 fail_compilation/b20011.d(37): cannot pass rvalue argument `S1(cast(ubyte)0u).member` of type `ubyte` to parameter `ref ubyte p`
10 fail_compilation/b20011.d(38): Error: function `b20011.main.assignableByOut(out ubyte p)` is not callable using argument types `(ubyte)`
11 fail_compilation/b20011.d(38): cannot pass rvalue argument `S1(cast(ubyte)0u).member` of type `ubyte` to parameter `out ubyte p`
12 fail_compilation/b20011.d(39): Error: function `b20011.main.assignableByConstRef(ref const(ubyte) p)` is not callable using argument types `(ubyte)`
13 fail_compilation/b20011.d(39): cannot pass rvalue argument `S1(cast(ubyte)0u).member` of type `ubyte` to parameter `ref const(ubyte) p`
14 ---
16 module b20011;
18 struct S1 { ubyte member; }
19 struct S2 { ubyte[] member; }
20 union U1 { ubyte m1; int m2; }
22 void main()
24 enum S1 s1 = {};
25 s1.member = 42;
27 enum S2 s2 = {};
28 s2.member = [];
29 s2.member ~= [];
31 enum U1 u1 = {m1 : 0};
32 u1.m2 = 42;
34 void assignableByRef(ref ubyte p){ p = 42; }
35 void assignableByOut(out ubyte p){ p = 42; }
36 void assignableByConstRef(ref const ubyte p){}
37 assignableByRef(s1.member);
38 assignableByOut(s1.member);
39 assignableByConstRef(s1.member);