1 /*
2 TEST_OUTPUT:
3 ---
4 fail_compilation/diag9148.d(19): Error: pure function 'diag9148.test9148a.foo' cannot access mutable static data 'g'
5 fail_compilation/diag9148.d(23): Error: pure function 'diag9148.test9148a.bar' cannot access mutable static data 'g'
6 fail_compilation/diag9148.d(24): Error: immutable function 'diag9148.test9148a.bar' cannot access mutable data 'x'
7 fail_compilation/diag9148.d(31): Error: pure function 'diag9148.test9148a.S.foo' cannot access mutable static data 'g'
8 fail_compilation/diag9148.d(35): Error: pure function 'diag9148.test9148a.S.bar' cannot access mutable static data 'g'
9 fail_compilation/diag9148.d(36): Error: immutable function 'diag9148.test9148a.S.bar' cannot access mutable data 'x'
10 ---
11 */
test9148a()12 void test9148a() pure
13 {
14     static int g;
15     int x;
16 
17     void foo() /+pure+/
18     {
19         g++;
20     }
21     void bar() immutable /+pure+/
22     {
23         g++;
24         x++;
25     }
26 
27     struct S
28     {
29         void foo() /+pure+/
30         {
31             g++;
32         }
33         void bar() immutable /+pure+/
34         {
35             g++;
36             x++;
37         }
38     }
39 }
40 
41 /*
42 TEST_OUTPUT:
43 ---
44 fail_compilation/diag9148.d(53): Error: static function diag9148.test9148b.foo cannot access frame of function diag9148.test9148b
45 ---
46 */
47 
48 void test9148b()
49 {
50     int x;
51     static void foo() pure
52     {
53         int y = x;
54     }
55 }
56