diff options
Diffstat (limited to 'gcc/testsuite/g++.old-deja/g++.mike/misc1.C')
-rw-r--r-- | gcc/testsuite/g++.old-deja/g++.mike/misc1.C | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.old-deja/g++.mike/misc1.C b/gcc/testsuite/g++.old-deja/g++.mike/misc1.C new file mode 100644 index 000000000..7a6021856 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/misc1.C @@ -0,0 +1,54 @@ +// { dg-do run } +// GROUPS passed construct-destruct +/* g++ constructs j 13 times, and destructs it once. */ + +extern "C" { + int printf (const char *, ...); + void exit(int); +} + +void foo() { +} + +class C { + int val; + public: + static int count; + C(int ii) { + val = ii; + ++count; + printf("up\n"); + } + ~C() { + --count; + printf("down\n"); + } + int operator ++() { + return ++val; + } + operator int() { + return val; + } +}; + +int C::count = 0; + +void bar() { + for (int ii=0; ii<13; ++ii) + for (C j=1; j<9; ++j) + foo(); +} + +int main() { + bar(); + if (C::count) + { + printf("FAIL\n"); + exit(1); + } + else + { + printf("PASS\n"); + } + return 0; +} |