Pick three bugfixes from next branch to trunk for inclusion in 4.5.0 RC2, as discusse...
[sdcc.git] / sdcc / support / regression / tests / bug-2995.c
blob76479560288356d0879d3bef897738362ac95d3f
1 /** bug-2995.c
2 Getting the address of an object in a named address space was
3 considered a read access of that space resulting in inefficiencies
4 (i.e. unnecessary calls to the function for switching address spaces).
5 */
7 #include <testfwk.h>
8 #include <stdbool.h>
10 bool a_accessed, b_accessed;
12 void set_a(void)
14 a_accessed = true;
17 void set_b(void)
19 b_accessed = true;
22 #if !defined(PORT_HOST) && !defined(__SDCC_pdk14) && !defined(__SDCC_pdk15) && !defined(__SDCC_mcs51) // For pdk14, pdk15 and mcs51: Need to pass segment ordering to linker somehow, to place space_a somewhere in RAM.
23 __addressmod set_a space_a;
24 __addressmod set_b space_b;
26 space_a int i;
27 space_a int *space_b j;
28 #endif
30 void testSpace(void)
32 #if !defined(PORT_HOST) && !defined(__SDCC_pdk14) && !defined(__SDCC_pdk15) && !defined(__SDCC_mcs51)
33 j = &i;
34 ASSERT (!a_accessed);
35 ASSERT (b_accessed);
36 #endif