]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/testsuite/gdc.test/fail_compilation/b20011.d
d: Import dmd b8384668f, druntime e6caaab9, phobos 5ab9ad256 (v2.098.0-beta.1)
[thirdparty/gcc.git] / gcc / testsuite / gdc.test / fail_compilation / b20011.d
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 ---
15 */
16 module b20011;
17
18 struct S1 { ubyte member; }
19 struct S2 { ubyte[] member; }
20 union U1 { ubyte m1; int m2; }
21
22 void main()
23 {
24 enum S1 s1 = {};
25 s1.member = 42;
26
27 enum S2 s2 = {};
28 s2.member = [];
29 s2.member ~= [];
30
31 enum U1 u1 = {m1 : 0};
32 u1.m2 = 42;
33
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);
40 }