summaryrefslogtreecommitdiff
path: root/support/regression/tests/bug-2995.c
blob: 76479560288356d0879d3bef897738362ac95d3f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/** bug-2995.c
    Getting the address of an object in a named address space was
    considered a read access of that space resulting in inefficiencies
    (i.e. unnecessary calls to the function for switching address spaces).
*/

#include <testfwk.h>
#include <stdbool.h>

bool a_accessed, b_accessed;

void set_a(void)
{
  a_accessed = true;
}

void set_b(void)
{
  b_accessed = true;
}

#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.
__addressmod set_a space_a;
__addressmod set_b space_b;

space_a int i; 
space_a int *space_b j;
#endif

void testSpace(void)
{
#if !defined(PORT_HOST) && !defined(__SDCC_pdk14) && !defined(__SDCC_pdk15) && !defined(__SDCC_mcs51)
  j = &i;
  ASSERT (!a_accessed);
  ASSERT (b_accessed);
#endif
}