* src/SDCCglue.c, support/regression/tests/bug2655200.c:
[fw/sdcc] / support / regression / tests / bug2655200.c
1 /*
2  * [ 2655200 ] pointer to pdata memory not correctly initialized
3  *
4  * test_array[..] = &thing_pdata
5  * was incorrect
6  *
7  * SDCCclue.c(initPointer)
8  * ... SPEC_SCLS (expr->left->etype) == S_PDATA)
9  * was not handeled
10  */
11
12 #include <testfwk.h>
13 #include <stdint.h>
14
15 #if !defined (SDCC_mcs51) && !defined (SDCC_ds390)
16 # define __code
17 #endif
18
19 char thing;
20 #if defined (SDCC_mcs51) || defined (SDCC_ds390)
21 __code char thing_code = 0;
22 __data char thing_data;
23 __idata char thing_idata;
24 __xdata char thing_xdata;
25 __pdata char thing_pdata;
26 __pdata char thing_apdata[2];
27 #endif
28
29
30 char * __code test_array[] = {
31  &thing
32 #if defined (SDCC_mcs51) || defined (SDCC_ds390)
33  , &thing_code
34  , &thing_data, &thing_idata, &thing_xdata, &thing_pdata
35  , thing_apdata, (char *)thing_apdata
36 #endif
37 };
38
39
40 char *gime_thing() { return &thing; }
41 #if defined (SDCC_mcs51) || defined (SDCC_ds390)
42 char *gime_thing_code() { return &thing_code; }
43 char *gime_thing_data() { return &thing_data; }
44 char *gime_thing_idata() { return &thing_idata; }
45 char *gime_thing_xdata() { return &thing_xdata; }
46 char *gime_thing_pdata() { return &thing_pdata; }
47 char *gime_thing_apdata() { return thing_apdata; }
48 #endif
49
50
51 void
52 testBug(void)
53 {
54 #if !defined (SDCC_MODEL_MEDIUM)        /* test-mcs51-medium fails */
55  ASSERT(test_array[0] == gime_thing());
56 #endif
57
58 #if defined (SDCC_mcs51) || defined (SDCC_ds390)
59  ASSERT(test_array[1] == gime_thing_code());
60  ASSERT(test_array[2] == gime_thing_data());
61  ASSERT(test_array[3] == gime_thing_idata());
62  ASSERT(test_array[4] == gime_thing_xdata());
63  ASSERT(test_array[5] == gime_thing_pdata());
64  ASSERT(test_array[6] == gime_thing_apdata());
65  ASSERT(test_array[7] == gime_thing_apdata());
66 #endif
67 }