source: Deliverables/D3.1/C-semantics/test/spaces.c @ 458

Last change on this file since 458 was 458, checked in by campbell, 9 years ago

Add a few more pointer tests.

File size: 1.4 KB
Line 
1
2void *ptrchange(__data void *p) { return p; }
3__data void *ptrchange2(void *p) { return p; }
4/* __data void *ptrchange3(__xdata void *p) { return p; } */
5
6void silly() {
7  __data int i = 5;
8}
9
10__data int * __xdata foo;
11
12__code int *incode;
13
14__data int * __xdata * __code bar = 0;
15/* Not handled by CompCert semantics
16__data int * __xdata * __code bar2 = &foo;
17*/
18
19__data int array1[5];
20
21__data int * __xdata array2[3];
22
23__data const int array_lit[] = { 1,1,2,3,5,8,13 };
24
25/* fn1 is a global variable located in idata memory,
26   which contains a pointer to a value in code memory,
27   which is a function that takes and returns a pointer to an integer in xdata.
28 */
29__xdata int * __code (* __idata fn1)(__xdata int *);
30
31int somegeneric = 2;
32__data int somedata = 3;
33__pdata int somepdata = 5;
34__xdata int somexdata = 7;
35__code int somecodedata = 11;
36
37__xdata int *f(__xdata int *p) { return p; }
38
39extern void dump(__data int * __xdata *v);
40
41int main(void) {
42  foo = &somedata;
43  __xdata void *dptr = &foo;
44  incode = &somecodedata;
45  dump(bar);
46  __xdata void *dptr2 = bar;
47  /* __xdata void *dptr2a = bar2;
48     __data void *dptr3 = *bar2;  See above */
49  __data void *dptr4 = array1+2;
50  __data int **dptr5 = array2;
51  __xdata void *dptr6 = &array2;
52  __data const int *dptr7 = array_lit+2;
53
54  fn1 = f;
55  __idata void *dptr8 = (__idata void *) fn1;
56  __xdata void *dptr9 = fn1(&somexdata);
57
58  return 0;
59}
Note: See TracBrowser for help on using the repository browser.