source: src/tests/multiDimension.c @ 136ccd7

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

Update multiDimension test

  • Property mode set to 100644
File size: 1.2 KB
RevLine 
[4e2a1137]1struct X {
2  int a;
3  int * ptr;
4};
5
[2afec66]6void ?{}(X & this) {
[4e2a1137]7  printf("default constructing\n");
[2afec66]8  (this.a){ 123 };
9  this.ptr = malloc(sizeof(int));
[4e2a1137]10}
11
[2afec66]12void ?{}(X & this, X other) {
[4e2a1137]13  printf("copy constructing\n");
[2afec66]14  (this.a){ other.a };
15  this.ptr = malloc(sizeof(int));
[4e2a1137]16}
17
[2afec66]18void ?{}(X & this, int a) {
[4e2a1137]19  printf("constructing with %d\n", a);
[2afec66]20  (this.a){ a };
21  this.ptr = malloc(sizeof(int));
[4e2a1137]22}
23
[2afec66]24void ^?{}(X & this) {
[4e2a1137]25  printf("destructing\n");
[2afec66]26  free(this.ptr);
[4e2a1137]27}
28
[2afec66]29X ?=?(X & this, X other) {
30  this.a = other.a;
31  return this;
[4e2a1137]32}
33
[0b9be4d]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// };
[4e2a1137]39
[0b9be4d]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// };
[4e2a1137]51
[0b9be4d]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// }
[4e2a1137]60
[e4719f0]61// ensure constructed const arrays continue to compile
[0b9be4d]62// const int global[1] = { -2 };
[e4719f0]63
[4e2a1137]64int main() {
[0b9be4d]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  // };
[4e2a1137]74
[0b9be4d]75  // foo();
76  // foo();
[4e2a1137]77}
Note: See TracBrowser for help on using the repository browser.