| 1 |
// { dg-do run } |
| 2 |
// GROUPS passed copy-ctors |
| 3 |
/* |
| 4 |
The old g++ output is |
| 5 |
|
| 6 |
Item() |
| 7 |
Compound() |
| 8 |
Pre foo |
| 9 |
foo |
| 10 |
~Compound() |
| 11 |
~Item() |
| 12 |
Post foo |
| 13 |
~Compound() |
| 14 |
~Item() |
| 15 |
|
| 16 |
The output should be something like (produced from ATT 2.1) |
| 17 |
|
| 18 |
Item() |
| 19 |
Compound() |
| 20 |
Pre foo |
| 21 |
Item(const Item& i) <------ missing above |
| 22 |
foo |
| 23 |
~Compound() |
| 24 |
~Item() |
| 25 |
Post foo |
| 26 |
~Compound() |
| 27 |
~Item() |
| 28 |
|
| 29 |
*/ |
| 30 |
|
| 31 |
extern "C" int printf (const char *, ...); |
| 32 |
extern "C" void exit (int); |
| 33 |
|
| 34 |
int count = 0; |
| 35 |
|
| 36 |
void |
| 37 |
die (int x) |
| 38 |
{ |
| 39 |
if (x != ++count) |
| 40 |
{ |
| 41 |
printf ("FAIL\n"); |
| 42 |
exit (1); |
| 43 |
} |
| 44 |
} |
| 45 |
|
| 46 |
|
| 47 |
class Item { |
| 48 |
public: |
| 49 |
Item() { die (1); } |
| 50 |
Item(const Item& i) { die (4); } |
| 51 |
~Item() { count++; if (count != 7 && count != 10) die (-1); } |
| 52 |
}; |
| 53 |
|
| 54 |
|
| 55 |
class Compound { |
| 56 |
Item i; |
| 57 |
public: |
| 58 |
Compound() { die (2); } |
| 59 |
~Compound() { count++; if (count != 6 && count != 9) die (-1); } |
| 60 |
}; |
| 61 |
|
| 62 |
|
| 63 |
void foo(Compound a) |
| 64 |
{ |
| 65 |
die (5); |
| 66 |
} |
| 67 |
|
| 68 |
int |
| 69 |
main() |
| 70 |
{ |
| 71 |
Compound a; |
| 72 |
|
| 73 |
die (3); |
| 74 |
foo(a); |
| 75 |
|
| 76 |
die (8); |
| 77 |
|
| 78 |
printf ("PASS\n"); |
| 79 |
} |
| 80 |
|