* as/hc08/asmain.c (asexit),
[fw/sdcc] / support / regression / tests / bug608752.c
1 /* OpAssign tests\r
2  */\r
3 #include <testfwk.h>\r
4 \r
5 #ifdef SDCC\r
6 #include <sdcc-lib.h>\r
7 #else\r
8 #define _STATMEM\r
9 #endif\r
10 \r
11 typedef struct\r
12 {\r
13   char a;\r
14   char n;\r
15 } item_type;\r
16 \r
17 item_type t;\r
18 \r
19 \r
20 _STATMEM item_type* get_next_item(void)\r
21 {\r
22   /* have a side effect */\r
23   t.n++;\r
24 \r
25   /* keep things easy, not implementing a list.\r
26      Using a true list would break things\r
27      even more pointedly:\r
28      a) reading beyond end of the list and\r
29      b) intermixing list members */\r
30   return &t;\r
31 }\r
32 \r
33 \r
34 void\r
35 testOpAssign(void)\r
36 {\r
37   t.a = 0;\r
38   t.n = 0;\r
39 \r
40   /* get_next_item() should be called only once */\r
41   get_next_item()->a |= 42;\r
42 \r
43   ASSERT (t.a == 42);\r
44   ASSERT (t.n == 1);\r
45 }\r