Debian Codegraph @

gcc/testsuite/g++.old-deja/g++.mike/misc1.C

raw
1 // { dg-do run }
2 // GROUPS passed construct-destruct
3 /* g++ constructs j 13 times, and destructs it once. */
4
5 extern "C" {
6 int printf (const char *, ...);
7 void exit(int);
8 }
9
10 void foo() {
11 }
12
13 class C {
14 int val;
15 public:
16 static int count;
17 C(int ii) {
18 val = ii;
19 ++count;
20 printf("up\n");
21 }
22 ~C() {
23 --count;
24 printf("down\n");
25 }
26 int operator ++() {
27 return ++val;
28 }
29 operator int() {
30 return val;
31 }
32 };
33
34 int C::count = 0;
35
36 void bar() {
37 for (int ii=0; ii<13; ++ii)
38 for (C j=1; j<9; ++j)
39 foo();
40 }
41
42 int main() {
43 bar();
44 if (C::count)
45 {
46 printf("FAIL\n");
47 exit(1);
48 }
49 else
50 {
51 printf("PASS\n");
52 }
53 return 0;
54 }