Changeset f7e749f for src/tests/memberCtors.c
- Timestamp:
- Dec 13, 2016, 3:56:44 PM (7 years ago)
- 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:
- fc638d2
- Parents:
- 0f35657
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/tests/memberCtors.c
r0f35657 rf7e749f 32 32 33 33 void ?{}(A * a, int x) { 34 printf("begin construct A\n"); 35 printf("construct a->x\n"); 34 36 (&a->x){ x+999 }; 37 printf("assign a->y\n"); 35 38 a->y = 0; // not a constructor - default constructor will be inserted 39 printf("end construct A\n"); 36 40 } // z never constructed - will be automatically default constructed 37 41 38 42 void ?{}(A * this, A other) { 43 printf("begin copy construct A\n"); 44 printf("copy construct this->x\n"); 39 45 (&this->x){ other.x }; 46 printf("assign this->y\n"); 40 47 this->y = other.y; // not a constructor - copy constructor will be inserted 48 printf("end copy construct A\n"); 41 49 } // z never constructed - will be automatically copy constructed 42 50 … … 46 54 47 55 void ?{}(B * b) { 56 printf("begin construct B\n"); 57 printf("assign b->a2\n"); 48 58 b->a2 = (A) { 2 }; 59 printf("construct b->a1\n"); 49 60 (&b->a1){ 1 }; 50 61 #ifdef ERR1 51 62 (&b->a2){ b->a3 }; // error, b->a2 was used previously but is explicitly constructed 52 63 #endif 64 printf("end construct B\n"); 53 65 } // a2, a3 never constructed - will be automatically default constructed 54 66
Note: See TracChangeset
for help on using the changeset viewer.