]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/testsuite/gdc.test/fail_compilation/fail10980.d
d: Import dmd b8384668f, druntime e6caaab9, phobos 5ab9ad256 (v2.098.0-beta.1)
[thirdparty/gcc.git] / gcc / testsuite / gdc.test / fail_compilation / fail10980.d
CommitLineData
b4c522fa
IB
1/*
2TEST_OUTPUT:
3---
5fee5ec3
IB
4fail_compilation/fail10980.d(22): Error: variable `fail10980.s1b` of type struct `immutable(S1)` uses `this(this)`, which is not allowed in static initialization
5fail_compilation/fail10980.d(28): Error: variable `fail10980.s1d` of type struct `immutable(S1)` uses `this(this)`, which is not allowed in static initialization
6fail_compilation/fail10980.d(27): Error: static variable `s1x` cannot be read at compile time
7fail_compilation/fail10980.d(28): called from here: `bar1()`
8fail_compilation/fail10980.d(38): Error: variable `fail10980.s2b` of type struct `immutable(S2)` uses `this(this)`, which is not allowed in static initialization
9fail_compilation/fail10980.d(44): Error: variable `fail10980.s2d` of type struct `immutable(S2)` uses `this(this)`, which is not allowed in static initialization
10fail_compilation/fail10980.d(43): Error: static variable `s2x` cannot be read at compile time
11fail_compilation/fail10980.d(44): called from here: `bar2()`
b4c522fa
IB
12---
13*/
14
15struct S1
16{
17 this(int) immutable {}
18 this(this) {}
19}
20alias immutable(S1) IS1;
21static immutable S1 s1a = IS1(1); // OK
22static immutable S1 s1b = s1a; // NG
23
24S1 foo1() { S1 s1x; S1 s1y = s1x; return s1y; }
25static immutable S1 s1c = foo1(); // OK
26
27ref S1 bar1() { static S1 s1x; return s1x; }
28static immutable S1 s1d = bar1(); // NG
29
30
31struct S2
32{
33 int val;
34 this(this) {}
35}
36alias immutable(S2) IS2;
37static immutable S2 s2a = IS2(1); // OK
38static immutable S2 s2b = s2a; // NG
39
40S2 foo2() { S2 s2x; S2 s2y = s2x; return s2y; }
41static immutable S2 s2c = foo2(); // OK
42
43ref S2 bar2() { static S2 s2x; return s2x; }
44static immutable S2 s2d = bar2(); // NG