OSDN Git Service

Initial revision
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / g++.old-deja / g++.mike / p7325.C
1 // I hate this type of test case.  I'm not sure how to code it better.
2 // See the PR for what this tests.
3 // prms-id: 7325
4 // execution test fails *-*-*
5
6 int fail = 0;
7
8 struct A {
9   int i;
10   static const A* match_this;
11   static const A* match_arg;
12   A(): i(7) {
13     if (match_this)
14       if (match_this != this)
15         fail = 1;
16   }
17   A* get_this() { return this; }
18   A& operator = (const A& o) {
19     if (match_this)
20       if (match_this != this)
21         fail = 1;
22     if (match_arg)
23       if (match_arg != &o)
24         fail = 1;
25     match_arg = &o;
26   }
27 };
28
29 const A* A::match_this;
30 const A* A::match_arg;
31 A a;
32
33 A foo() { return a; }
34 void f ()
35 {
36   A a;
37   A::match_this = &a;
38   a = foo ();
39   a = foo ();
40   A::match_this = 0;
41 }
42
43 void g ()
44 {
45   A::match_this = A().get_this();
46   A();
47   A();
48   A::match_this = 0;
49 }
50
51 main() {
52   f();
53   g();
54   return fail;
55 }