summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.old-deja/g++.other/call1.C
blob: e12cffedf4f6ebc86f17bf7ce8d8e49ecbebe6f9 (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
// { dg-do run  }
// Test that various calls to non-functions work.

void f () { }

typedef void (*fptr)();
typedef void (&fref)();
fptr p = f;
fref r = f;
const fptr &pr = p;

struct A {
  fptr p;

  A (fptr n): p(n) { }
  operator fptr () { return p; }
};

struct B {
  fref r;

  B (fptr n): r(*n) { }
  operator const fref () { return r; }
};

struct C {
  const fptr pr;

  C (fptr n): pr(n) { }
  operator const fptr& () { return pr; }
};

int main ()
{
  f();

  p();
  r();
  pr();

  A a (f);
  a();
  a.p();

  B b (f);
  b();
  b.r();

  C c (f);
  c();
  c.pr();
}