struct / union in initializer, RFE #901.
[sdcc.git] / sdcc / support / regression / tests / bug2655200.c
blob00161083a4c117dfd87715b9b48e3b072a88d5c2
1 /*
2 * [ 2655200 ] pointer to pdata memory not correctly initialized
4 * test_array[..] = &thing_pdata
5 * was incorrect
7 * SDCCclue.c(initPointer)
8 * ... SPEC_SCLS (expr->left->etype) == S_PDATA)
9 * was not handled
12 #include <testfwk.h>
13 #include <stdint.h>
15 char thing;
16 #if defined (__SDCC_mcs51) || defined (__SDCC_ds390)
17 __code char thing_code = 0;
18 __data char thing_data;
19 __idata char thing_idata;
20 __xdata char thing_xdata;
21 __pdata char thing_pdata;
22 __pdata char thing_apdata[2];
23 #endif
26 const char * __code test_array[] = {
27 &thing
28 #if defined (__SDCC_mcs51) || defined (__SDCC_ds390)
29 , &thing_code
30 , &thing_data, &thing_idata, &thing_xdata, &thing_pdata
31 , thing_apdata, (char *)thing_apdata
32 #endif
36 const char *gime_thing() { return &thing; }
37 #if defined (__SDCC_mcs51) || defined (__SDCC_ds390)
38 const char *gime_thing_code() { return &thing_code; }
39 const char *gime_thing_data() { return &thing_data; }
40 const char *gime_thing_idata() { return &thing_idata; }
41 const char *gime_thing_xdata() { return &thing_xdata; }
42 const char *gime_thing_pdata() { return &thing_pdata; }
43 const char *gime_thing_apdata() { return thing_apdata; }
44 #endif
47 void
48 testBug(void)
50 ASSERT(test_array[0] == gime_thing());
52 #if defined (__SDCC_mcs51) || defined (__SDCC_ds390)
53 ASSERT(test_array[1] == gime_thing_code());
54 ASSERT(test_array[2] == gime_thing_data());
55 ASSERT(test_array[3] == gime_thing_idata());
56 ASSERT(test_array[4] == gime_thing_xdata());
57 ASSERT(test_array[5] == gime_thing_pdata());
58 ASSERT(test_array[6] == gime_thing_apdata());
59 ASSERT(test_array[7] == gime_thing_apdata());
60 #endif