source: tests/raii/multiDimension.cfa @ ad47ec4

Last change on this file since ad47ec4 was 107b01a, checked in by Thierry Delisle <tdelisle@…>, 6 years ago

Several changes to the makefiles

  • change .c tests to .cfa
  • add require for libtool in configure
  • libtoolize to fix some warnings
  • Property mode set to 100644
File size: 1.1 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 };
[cdbfab0]9  this.ptr = (int *)malloc(sizeof(int));
[4e2a1137]10}
11
[2afec66]12void ?{}(X & this, X other) {
[4e2a1137]13  printf("copy constructing\n");
[2afec66]14  (this.a){ other.a };
[cdbfab0]15  this.ptr = (int *)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 };
[cdbfab0]21  this.ptr = (int *)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
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
[e4719f0]61// ensure constructed const arrays continue to compile
62const int global[1] = { -2 };
63
[4e2a1137]64int main() {
65  X abc[4][4] = {
66    { 999, 1111 },
67    { 1, 2, 3, 4, 5 },
68    {},
69    { 0 },
70    { 88 }
71  };
72
73  foo();
74  foo();
75}
Note: See TracBrowser for help on using the repository browser.