3 storage: auto, __idata, __pdata, __xdata, __code,
6 #define STORAGE_{storage}
7 #define STORAGE {storage}
10 #if defined (__GNUC__) && defined (__alpha__) && (__GNUC__ < 3)
11 /* since g fails on GCC 2.95.4 on alpha... */
14 #elif defined (STORAGE_auto)
15 /* only static flexible arrays are allowed */
26 #ifndef __SDCC_pdk14 // Lack of memory
28 #if defined (STORAGE_auto)
32 extern char STORAGE bug1470790
[3];
33 char STORAGE bug1470790
[] = {1, };
37 const char *string1
= "\x00\x01";
38 const char string2
[] = "\x00\x01";
41 #pragma disable_warning 147 //no warning about excess initializers (W_EXCESS_INITIALIZERS)
42 #pragma disable_warning 85 //no warning about unreferenced variables (W_NO_REFERENCE)
43 //array will be truncated but warning will be suppressed
44 //if truncation is incorrect, other ASSERTs will fail with high probability
45 char STORAGE trunc
[2] = {'a', 'b', 'c'};
48 char STORAGE array
[5] = {'a', 'b', 'c'};
66 struct x STORAGE teststruct
[5] = {
67 { 10, { 1, 2, 3, 4, 5} },
78 struct y STORAGE incompletestruct
= {
89 struct z STORAGE funcptrstruct
= {
93 #if !defined (STORAGE_auto)
97 ASSERT (bug1470790
[0] == 1);
98 ASSERT (bug1470790
[1] == 0);
101 ASSERT (string1
[0] == '\x00');
102 ASSERT (string1
[1] == '\x01');
103 ASSERT (string2
[0] == '\x00');
104 ASSERT (string2
[1] == '\x01');
106 ASSERT (array
[2] == 'c');
107 ASSERT (array
[4] == 0);
110 ASSERT (g
[1].a
== 'y');
111 ASSERT (g
[1].b
== 0);
112 ASSERT (g
[2].a
== 'z');
113 ASSERT (g
[2].b
== 3);
116 ASSERT (teststruct
[0].b
[1] == 2);
117 ASSERT (teststruct
[0].b
[5] == 0);
118 ASSERT (teststruct
[1].b
[0] == 11);
119 ASSERT (teststruct
[4].b
[9] == 0);
121 ASSERT (sizeof(teststruct
[2].a
) == 2);
122 ASSERT (sizeof(teststruct
[1].b
) == 10);
123 ASSERT (sizeof(teststruct
[1]) == 12);
124 ASSERT (sizeof(teststruct
) == 60);
127 ASSERT (incompletestruct
.a
== 10);
128 ASSERT (incompletestruct
.b
[0] == 1);
129 ASSERT (incompletestruct
.b
[4] == 5);
131 ASSERT (sizeof (incompletestruct
) == sizeof (struct y
));
132 ASSERT (sizeof (incompletestruct
) == offsetof (struct y
, b
));
133 ASSERT (sizeof (incompletestruct
) == offsetof (struct x
, b
));
136 #if defined (STORAGE_auto)
141 teststruct
[0].b
[5] = 1;
142 teststruct
[4].b
[9] = 1;
143 #endif //STORAGE_auto
150 #ifndef __SDCC_pdk14 // Lack of memory
153 #if defined (STORAGE_auto)
154 Zeropad (); //test reinitialization
155 #endif //STORAGE_auto