aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/g++.dg/opt/delay-slot-1.C
blob: d435873cc31542e623d65b24a9d4fd1a71ea9bfd (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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
/* PR rtl-optimization/23585 */
/* Testcase by Matti Rintala <matti.rintala@iki.fi> */

/* { dg-do run } */
/* { dg-options "-O2" } */

template <class _Ret, class _Tp>
class const_mem_fun_t
{
public:
  explicit
  const_mem_fun_t(_Ret (_Tp::*__pf)() const)
    : _M_f(__pf) {}
  
  _Ret
  operator()(const _Tp* __p) const
  { return (__p->*_M_f)(); }
private:
  _Ret (_Tp::*_M_f)() const;
};

template <class _Ret, class _Tp>
class const_mem_fun_ref_t
{
public:
  explicit
  const_mem_fun_ref_t(_Ret (_Tp::*__pf)() const)
    : _M_f(__pf) {}
  
  _Ret
  operator()(const _Tp& __r) const
  { return (__r.*_M_f)(); }
private:
  _Ret (_Tp::*_M_f)() const;
};

template <class _Ret, class _Tp, class _Arg>
class const_mem_fun1_t
{
public:
  explicit
  const_mem_fun1_t(_Ret (_Tp::*__pf)(_Arg) const)
    : _M_f(__pf) {}
  
  _Ret
  operator()(const _Tp* __p, _Arg __x) const
  { return (__p->*_M_f)(__x); }
private:
  _Ret (_Tp::*_M_f)(_Arg) const;
};


template <class _Ret, class _Tp, class _Arg>
class const_mem_fun1_ref_t
{
public:
  explicit
  const_mem_fun1_ref_t(_Ret (_Tp::*__pf)(_Arg) const)
    : _M_f(__pf) {}
  
  _Ret
  operator()(const _Tp& __r, _Arg __x) const
  { return (__r.*_M_f)(__x); }
private:
  _Ret (_Tp::*_M_f)(_Arg) const;
};

template <class _Ret, class _Tp>
inline const_mem_fun_t<_Ret, _Tp>
mem_fun(_Ret (_Tp::*__f)() const)
{ return const_mem_fun_t<_Ret, _Tp>(__f); }

template <class _Ret, class _Tp>
inline const_mem_fun_ref_t<_Ret, _Tp>
mem_fun_ref(_Ret (_Tp::*__f)() const)
{ return const_mem_fun_ref_t<_Ret, _Tp>(__f); }

template <class _Ret, class _Tp, class _Arg>
inline const_mem_fun1_t<_Ret, _Tp, _Arg>
mem_fun(_Ret (_Tp::*__f)(_Arg) const)
{ return const_mem_fun1_t<_Ret, _Tp, _Arg>(__f); }

template <class _Ret, class _Tp, class _Arg>
inline const_mem_fun1_ref_t<_Ret, _Tp, _Arg>
mem_fun_ref(_Ret (_Tp::*__f)(_Arg) const)
{ return const_mem_fun1_ref_t<_Ret, _Tp, _Arg>(__f); }

class Klasse {
public:
  void vf0c() const;
  void vf1c(const int&) const;
};

int main()
{
  Klasse obj;
  const Klasse& objc = obj;

  mem_fun(&Klasse::vf0c)(&objc);
  mem_fun(&Klasse::vf1c)(&objc, 1);

  mem_fun_ref(&Klasse::vf0c)(objc);
  mem_fun_ref(&Klasse::vf1c)(objc, 1);
  return 0;
}

void Klasse::vf0c() const
{}

void Klasse::vf1c(const int&) const
{}