Ignore:
Timestamp:
Jul 26, 2017, 5:24:33 PM (7 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
25bd9074
Parents:
8a6cf7e
Message:

Update several tests for references

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/tests/memberCtors.c

    r8a6cf7e r2afec66  
    33};
    44
    5 void ?{}(WrappedInt * this) {
     5void ?{}(WrappedInt & this) {
    66  printf("constructing int\n");
    7   this->x = 0;
     7  this.x = 0;
    88}
    99
    10 void ?{}(WrappedInt * this, WrappedInt other) {
     10void ?{}(WrappedInt & this, WrappedInt other) {
    1111  printf("copy constructing int: %d\n", other.x);
    12   this->x = other.x;
     12  this.x = other.x;
    1313}
    1414
    15 void ?{}(WrappedInt * this, int x) {
     15void ?{}(WrappedInt & this, int x) {
    1616  printf("constructing int: %d\n", x);
    17   this->x = x;
     17  this.x = x;
    1818}
    1919
    20 void ^?{}(WrappedInt * this) {
    21   printf("destructing int: %d\n", this->x);
     20void ^?{}(WrappedInt & this) {
     21  printf("destructing int: %d\n", this.x);
    2222}
    2323
    24 void ?=?(WrappedInt * this, int x) {
    25   printf("assigning int: %d %d\n", this->x, x);
    26   this->x = x;
     24void ?=?(WrappedInt & this, int x) {
     25  printf("assigning int: %d %d\n", this.x, x);
     26  this.x = x;
    2727}
    2828
     
    3131};
    3232
    33 void ?{}(A * a) {
     33void ?{}(A & a) {
    3434  // currently must define default ctor, since there's no "= default" syntax
    3535}
    3636
    37 void ?{}(A * a, int x) {
     37void ?{}(A & a, int x) {
    3838  printf("begin construct A\n");
    39   printf("construct a->x\n");
    40   (&a->x){ x+999 };
    41   printf("assign a->y\n");
    42   a->y = 0; // not a constructor - default constructor will be inserted
     39  printf("construct a.x\n");
     40  (a.x){ x+999 };
     41  printf("assign a.y\n");
     42  a.y = 0; // not a constructor - default constructor will be inserted
    4343  printf("end construct A\n");
    4444} // z never constructed - will be automatically default constructed
    4545
    46 void ?{}(A * this, A other) {
     46void ?{}(A & this, A other) {
    4747  printf("begin copy construct A\n");
    48   printf("copy construct this->x\n");
    49   (&this->x){ other.x };
    50   printf("assign this->y\n");
    51   this->y = other.y; // not a constructor - copy constructor will be inserted
     48  printf("copy construct this.x\n");
     49  (this.x){ other.x };
     50  printf("assign this.y\n");
     51  this.y = other.y; // not a constructor - copy constructor will be inserted
    5252  printf("end copy construct A\n");
    5353} // z never constructed - will be automatically copy constructed
    5454
    55 A ?=?(A * this, A other) {
     55A ?=?(A & this, A other) {
    5656  printf("begin ?=? A\n");
    57   this->x = other.x;
    58   this->y = other.y;
    59   this->z = other.z;
     57  this.x = other.x;
     58  this.y = other.y;
     59  this.z = other.z;
    6060  printf("end ?=? A\n");
    61   return *this;
     61  return this;
    6262}
    6363
     
    6666};
    6767
    68 void ?{}(B * b) {
     68void ?{}(B & b) {
    6969  printf("begin construct B\n");
    70   printf("assign b->a2\n");
    71   b->a2 = (A) { 2 };
    72   printf("construct b->a1\n");
    73   (&b->a1){ 1 };
     70  printf("assign b.a2\n");
     71  b.a2 = (A) { 2 };
     72  printf("construct b.a1\n");
     73  (b.a1){ 1 };
    7474#ifdef ERR1
    75   (&b->a2){ b->a3 }; // error, b->a2 was used previously but is explicitly constructed
     75  (b.a2){ b.a3 }; // error, b->a2 was used previously but is explicitly constructed
    7676#endif
    7777  printf("end construct B\n");
    7878} // a2, a3 never constructed - will be automatically default constructed
    7979
    80 void ^?{}(B * b) {
    81   b->a2 = (A) { 0 };
    82   ^(&b->a1){};
     80void ^?{}(B & b) {
     81  b.a2 = (A) { 0 };
     82  ^(b.a1){};
    8383} // a2, a3 never destructed - will be automatically destructed
    8484
Note: See TracChangeset for help on using the changeset viewer.