source: src/tests/multiDimension.c @ c3acb841

ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsdeferred_resndemanglerenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newwith_gc
Last change on this file since c3acb841 was 4e2a1137, checked in by Rob Schluntz <rschlunt@…>, 8 years ago

add test case for multidimensional arrays

  • Property mode set to 100644
File size: 1.0 KB
Line 
1struct X {
2  int a;
3  int * ptr;
4};
5
6void ?{}(X * this) {
7  printf("default constructing\n");
8  (&this->a){ 123 };
9  this->ptr = malloc(sizeof(int));
10}
11
12void ?{}(X * this, X other) {
13  printf("copy constructing\n");
14  (&this->a){ other.a };
15  this->ptr = malloc(sizeof(int));
16}
17
18void ?{}(X * this, int a) {
19  printf("constructing with %d\n", a);
20  (&this->a){ a };
21  this->ptr = malloc(sizeof(int));
22}
23
24void ^?{}(X * this) {
25  printf("destructing\n");
26  free(this->ptr);
27}
28
29X ?=?(X * this, X other) {
30  this->a = other.a;
31  return *this;
32}
33
34X global[10][10] = {
35  { 1, { 2 }, { 3 }, { 4 }, 5, 6, 7, 8, 9, 10, 11, 12 },
36  { 1, 2, 3, 4 },
37  { { 1234567 } }
38};
39
40X global2[3][3][3] = {
41  {
42    { 1, 2, 3 },
43    { 4, 5, 6 },
44    { 7, 8, 9 },
45    { 10, 11, 12 }
46  },
47  {
48    { 0, 0, 0 }
49  }
50};
51
52int foo() {
53  static X abc[3][3] = {
54    { 11, 22, 33, 44 },
55    { 55, 66 },
56    { 77 },
57    { 88, 99, 1010 }
58  };
59}
60
61int main() {
62  X abc[4][4] = {
63    { 999, 1111 },
64    { 1, 2, 3, 4, 5 },
65    {},
66    { 0 },
67    { 88 }
68  };
69
70  foo();
71  foo();
72}
Note: See TracBrowser for help on using the repository browser.