summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gdc.test/fail_compilation/fail17491.d
blob: 4902392cf0fef4ae22254f57b32f08411059e5a4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/* TEST_OUTPUT:
---
fail_compilation/fail17491.d(24): Error: (S17491).init is not an lvalue
fail_compilation/fail17491.d(25): Error: S17491(0) is not an lvalue
fail_compilation/fail17491.d(27): Error: constant S17491(0).field is not an lvalue
fail_compilation/fail17491.d(28): Error: constant *&S17491(0).field is not an lvalue
fail_compilation/fail17491.d(33): Error: S17491(0) is not an lvalue
fail_compilation/fail17491.d(34): Error: S17491(0) is not an lvalue
fail_compilation/fail17491.d(36): Error: constant S17491(0).field is not an lvalue
fail_compilation/fail17491.d(37): Error: constant *&S17491(0).field is not an lvalue
---
*/

// https://issues.dlang.org/show_bug.cgi?id=17491

struct S17491
{
    int field;
    static int var;
}

void test17491()
{
    S17491.init = S17491(42);       // NG
    *&S17491.init = S17491(42);     // NG

    S17491.init.field = 42;         // NG
    *&S17491.init.field = 42;       // Should be NG

    S17491.init.var = 42;           // OK
    *&S17491.init.var = 42;         // OK

    S17491(0) = S17491(42);         // NG
    *&S17491(0) = S17491(42);       // NG

    S17491(0).field = 42;           // NG
    *&S17491(0).field = 42;         // Should be NG

    S17491(0).var = 42;             // OK
    *&S17491(0).var = 42;           // OK
}