aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.old-deja/g++.mike/p7325.C
blob: 9cf4604daabc27c66024b3484849043abdbbfec6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// I hate this type of test case.  I'm not sure how to code it better.
// See the PR for what this tests.
// prms-id: 7325
// execution test - XFAIL *-*-*

int fail = 0;

struct A {
  int i;
  static const A* match_this;
  static const A* match_arg;
  A(): i(7) {
    if (match_this)
      if (match_this != this)
	fail = 1;
  }
  A* get_this() { return this; }
  A& operator = (const A& o) {
    if (match_this)
      if (match_this != this)
	fail = 1;
    if (match_arg)
      if (match_arg != &o)
	fail = 1;
    match_arg = &o;
  }
};

const A* A::match_this;
const A* A::match_arg;
A a;

A foo() { return a; }
void f ()
{
  A a;
  A::match_this = &a;
  a = foo ();
  a = foo ();
  A::match_this = 0;
}

void g ()
{
  A::match_this = A().get_this();
  A();
  A();
  A::match_this = 0;
}

main() {
  f();
  g();
  return fail;
}