summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.old-deja/g++.pt/ptrmem2.C
blob: f14611c1af25c0ae55c6e73990963d037c5e95cc (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
// { dg-do run  }
struct S;

template <S* (S::*p)()>
struct F {
  S* f (S& s)
    {
      return (s.*p)();
    }
};

template <int S::*p>
struct D {
  void d (S& s)
    {
      (s.*p) = 3;
    }
};

struct S {
  S* g ();
  int i;
  F<&S::g> fg;
  D<&S::i> di;
  S* h(), k(F<&S::h>);
  F<&S::g> fg2;
  D<&S::i> di2;
};

S* S::g()
{
  return this;
}

S* S::h()
{
  return this;
}

int main()
{
  S s;
  s.i = 2;
  s.di.d (s);
  if (s.i != 3)
    return 1;
  if (s.fg2.f(s) != &s)
    return 1;
}