source: src/tests/multiDimension.c @ 4ee1efb

ADTarm-ehast-experimentalcleanup-dtorsenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprpthread-emulationqualifiedEnum
Last change on this file since 4ee1efb was 0b9be4d, checked in by Rob Schluntz <rschlunt@…>, 7 years ago

Update multiDimension test

  • Property mode set to 100644
File size: 1.2 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
34// X 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
40// X 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
52// int foo() {
53//   static X abc[3][3] = {
54//     { 11, 22, 33, 44 },
55//     { 55, 66 },
56//     { 77 },
57//     { 88, 99, 1010 }
58//   };
59// }
60
61// ensure constructed const arrays continue to compile
62// const int global[1] = { -2 };
63
64int main() {
65  X a;
66  X abc[2];
67  // X abc[4]/*[4]*/ = {
68  //   /*{*/ 999, 1111 /*}*/,
69  //   // { 1, 2, 3, 4, 5 },
70  //   // {},
71  //   // { 0 },
72  //   // { 88 }
73  // };
74
75  // foo();
76  // foo();
77}
Note: See TracBrowser for help on using the repository browser.