summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gdc.test/fail_compilation/test16095.d
blob: 38a3a7dfbc9d135337f35c0fc042abaffd2722cd (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
42
/*
TEST_OUTPUT:
---
fail_compilation/test16095.d(18): Error: `shared` method `test16095.C.ping` is not callable using a non-shared `a`
fail_compilation/test16095.d(28): Error: `shared` method `test16095.S.ping` is not callable using a non-shared `*a`
fail_compilation/test16095.d(41): Error: mutable method `test16095.Foo.flip` is not callable using a `immutable` `foo`
---
*/
// https://issues.dlang.org/show_bug.cgi?id=16095

class C
{
    void ping() shared;
}

void test1(C a)
{
    (&a.ping)(); // error
}

struct S
{
    void ping() shared;
}

void test2(S* a)
{
    (&a.ping)(); // error
}

struct Foo {
   bool flag;
   void flip() {
        flag = true;
   }
}

void test3()
{
    immutable Foo foo;
    (&foo.flip)();      // error
}