2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / gcc / testsuite / g++.old-deja / g++.mike / p7325.C
blob621adeb8a8503177462ee61df74978ca6032b585
1 // { dg-do run { xfail *-*-* } }
2 // I hate this type of test case.  I'm not sure how to code it better.
3 // See the PR for what this tests.
4 // prms-id: 7325
6 int fail = 0;
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     return *this;
27   }
30 const A* A::match_this;
31 const A* A::match_arg;
32 A a;
34 A foo() { return a; }
35 void f ()
37   A a;
38   A::match_this = &a;
39   a = foo ();
40   a = foo ();
41   A::match_this = 0;
44 void g ()
46   A::match_this = A().get_this();
47   A();
48   A();
49   A::match_this = 0;
52 int main() {
53   f();
54   g();
55   return fail;