diff options
author | upstream source tree <ports@midipix.org> | 2015-03-15 20:14:05 -0400 |
---|---|---|
committer | upstream source tree <ports@midipix.org> | 2015-03-15 20:14:05 -0400 |
commit | 554fd8c5195424bdbcabf5de30fdc183aba391bd (patch) | |
tree | 976dc5ab7fddf506dadce60ae936f43f58787092 /gcc/testsuite/g++.dg/opt/delay-slot-1.C | |
download | cbb-gcc-4.6.4-upstream.tar.bz2 cbb-gcc-4.6.4-upstream.tar.xz |
obtained gcc-4.6.4.tar.bz2 from upstream website;upstream
verified gcc-4.6.4.tar.bz2.sig;
imported gcc-4.6.4 source tree from verified upstream tarball.
downloading a git-generated archive based on the 'upstream' tag
should provide you with a source tree that is binary identical
to the one extracted from the above tarball.
if you have obtained the source via the command 'git clone',
however, do note that line-endings of files in your working
directory might differ from line-endings of the respective
files in the upstream repository.
Diffstat (limited to 'gcc/testsuite/g++.dg/opt/delay-slot-1.C')
-rw-r--r-- | gcc/testsuite/g++.dg/opt/delay-slot-1.C | 111 |
1 files changed, 111 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.dg/opt/delay-slot-1.C b/gcc/testsuite/g++.dg/opt/delay-slot-1.C new file mode 100644 index 000000000..d435873cc --- /dev/null +++ b/gcc/testsuite/g++.dg/opt/delay-slot-1.C @@ -0,0 +1,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 +{} |