Ignore:
Timestamp:
Aug 28, 2018, 6:30:11 PM (3 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
arm-eh, cleanup-dtors, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr
Children:
f8b69da7
Parents:
b54ad9c
Message:

Update memberCtors test to add more information

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tests/raii/memberCtors.c

    rb54ad9c ra42a654  
    11struct WrappedInt {
    22  int x;
     3  int id;
    34};
     5int intID = 0;
    46
    57void ?{}(WrappedInt & this) {
    6   printf("constructing int\n");
     8  this.id = intID++;
     9  printf("constructing int id: %d\n", this.id);
    710  this.x = 0;
    811}
    912
    1013void ?{}(WrappedInt & this, WrappedInt other) {
    11   printf("copy constructing int: %d\n", other.x);
     14  this.id = intID++;
     15  printf("copy constructing int: %d id: %d\n", other.x, this.id);
    1216  this.x = other.x;
    1317}
    1418
    1519void ?{}(WrappedInt & this, int x) {
    16   printf("constructing int: %d\n", x);
     20  this.id = intID++;
     21  printf("constructing int: %d id: %d\n", x, this.id);
    1722  this.x = x;
    1823}
    1924
    2025void ^?{}(WrappedInt & this) {
    21   printf("destructing int: %d\n", this.x);
     26  printf("destructing int: %d id: %d\n", this.x, this.id);
    2227}
    2328
    2429/* WrappedInt */ void ?=?(WrappedInt & this, int x) {
    25   printf("assigning int: %d %d\n", this.x, x);
     30  printf("assigning int: %d %d id: %d\n", this.x, x, this.id);
    2631  this.x = x;
    2732  // return this;
     
    3641struct A {
    3742  WrappedInt x, y, z;
     43  int id;
    3844};
     45int AID = 0;
    3946
    4047void ?{}(A & a) {
    4148  // currently must define default ctor, since there's no "= default" syntax
     49  a.id = AID++;
     50  printf("default construct A %d\n", a.id);
    4251}
    4352
    4453void ?{}(A & a, int x) {
    45   printf("begin construct A\n");
     54  a.id = AID++;
     55  printf("begin construct A id: %d\n", a.id);
    4656  printf("construct a.x\n");
    4757  (a.x){ x+999 };
     
    5262
    5363void ?{}(A & this, A other) {
    54   printf("begin copy construct A\n");
     64  this.id = AID++;
     65  printf("begin copy construct A id: %d\n", this.id);
    5566  printf("copy construct this.x\n");
    5667  (this.x){ other.x };
     
    6172
    6273A ?=?(A & this, A other) {
    63   printf("begin ?=? A\n");
     74  printf("begin ?=? A id: %d\n", this.id);
    6475  this.x = other.x;
    6576  this.y = other.y;
     
    7182struct B {
    7283  A a1, a2, a3;
     84  int id;
    7385};
     86int BID = 0;
    7487
    7588void ?{}(B & b) {
    76   printf("begin construct B\n");
     89  b.id = BID++;
     90  printf("begin construct B id: %d\n", b.id);
    7791  printf("assign b.a2\n");
    7892  b.a2 = (A) { 2 };
     
    86100
    87101void ^?{}(B & b) {
    88   printf("begin destruct B\n");
     102  b.id = BID++;
     103  printf("begin destruct B id: %d\n", b.id);
    89104  b.a2 = (A) { 0 };
    90105  ^(b.a1){};
Note: See TracChangeset for help on using the changeset viewer.