OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [g++.dg/] [torture/] [pr40991.C] - Blame information for rev 774

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 693 jeremybenn
/* { dg-options "-std=gnu++0x" } */
2
 
3
typedef __SIZE_TYPE__ size_t;
4
namespace std __attribute__ ((__visibility__ ("default"))) {
5
    using ::size_t;
6
    void __throw_bad_function_call() __attribute__((__noreturn__));
7
}
8
inline void* operator new(std::size_t, void* __p) throw() {
9
    return __p;
10
}
11
namespace std {
12
    class type_info {
13
    public:
14
        bool operator==(const type_info& __arg) const { }
15
    };
16
    namespace tr1 {
17
        template struct integral_constant { };
18
        typedef integral_constant true_type;
19
        template
20
        struct _Maybe_unary_or_binary_function { };
21
        class _Undefined_class;
22
        union _Nocopy_types {
23
            void (_Undefined_class::*_M_member_pointer)();
24
        };
25
        union _Any_data {
26
            void* _M_access() {
27
                return &_M_pod_data[0];
28
            }
29
            char _M_pod_data[sizeof(_Nocopy_types)];
30
        };
31
        enum _Manager_operation { __get_type_info, __get_functor_ptr, __clone_functor, __destroy_functor };
32
        template struct _Simple_type_wrapper {
33
            _Simple_type_wrapper(_Tp __value) : __value(__value) { }
34
            _Tp __value;
35
        };
36
        template class function;
37
        class _Function_base {
38
        public:
39
            static const std::size_t _M_max_size = sizeof(_Nocopy_types);
40
            static const std::size_t _M_max_align = __alignof__(_Nocopy_types);
41
            template class _Base_manager {
42
                static const bool __stored_locally = (sizeof(_Functor) <= _M_max_size && __alignof__(_Functor) <= _M_max_align && (_M_max_align % __alignof__(_Functor) == 0));
43
                typedef integral_constant _Local_storage;
44
            public:
45
                static bool _M_manager(_Any_data& __dest, const _Any_data& __source, _Manager_operation __op) { }
46
                static void _M_init_functor(_Any_data& __functor, const _Functor& __f) {
47
                    _M_init_functor(__functor, __f, _Local_storage());
48
                }
49
                template static bool _M_not_empty_function(_Tp _Class::* const& __mp) {
50
                    return __mp;
51
                }
52
                static void _M_init_functor(_Any_data& __functor, const _Functor& __f, true_type) {
53
                    new (__functor._M_access()) _Functor(__f);
54
                }
55
            };
56
            ~_Function_base() {
57
                if (_M_manager) _M_manager(_M_functor, _M_functor, __destroy_functor);
58
            }
59
            bool _M_empty() const {
60
                return !_M_manager;
61
            }
62
            typedef bool (*_Manager_type)(_Any_data&, const _Any_data&, _Manager_operation);
63
            _Any_data _M_functor;
64
            _Manager_type _M_manager;
65
        };
66
        template class _Function_handler;
67
        template class _Function_handler<_Res(_ArgTypes...), _Member _Class::*> : public _Function_handler {
68
        public:
69
            static _Res _M_invoke(const _Any_data& __functor, _ArgTypes... __args) { }
70
        };
71
        template class _Function_handler : public _Function_base::_Base_manager< _Simple_type_wrapper< _Member _Class::* > > { };
72
        template class function<_Res(_ArgTypes...)> : public _Maybe_unary_or_binary_function<_Res, _ArgTypes...>, private _Function_base {
73
            typedef _Res _Signature_type(_ArgTypes...);
74
            struct _Useless { };
75
        public:
76
            template function(_Functor __f, _Useless = _Useless());
77
            _Res operator()(_ArgTypes... __args) const;
78
            const type_info& target_type() const;
79
            typedef _Res (*_Invoker_type)(const _Any_data&, _ArgTypes...);
80
            _Invoker_type _M_invoker;
81
        };
82
        template template function<_Res(_ArgTypes...)>:: function(_Functor __f, _Useless) : _Function_base() {
83
            typedef _Function_handler<_Signature_type, _Functor> _My_handler;
84
            if (_My_handler::_M_not_empty_function(__f)) {
85
                _M_invoker = &_My_handler::_M_invoke;
86
                _M_manager = &_My_handler::_M_manager;
87
                _My_handler::_M_init_functor(_M_functor, __f);
88
            }
89
        }
90
        template _Res function<_Res(_ArgTypes...)>:: operator()(_ArgTypes... __args) const {
91
            if (_M_empty()) {
92
                __throw_bad_function_call();
93
            }
94
            return _M_invoker(_M_functor, __args...);
95
        }
96
        template const type_info& function<_Res(_ArgTypes...)>:: target_type() const {
97
            if (_M_manager) {
98
                _Any_data __typeinfo_result;
99
                _M_manager(__typeinfo_result, _M_functor, __get_type_info);
100
            }
101
        }
102
    }
103
}
104
struct X {
105
    int bar;
106
};
107
void test05() {
108
    using std::tr1::function;
109
    X x;
110
    function frm(&X::bar);
111
    frm(x) == 17;
112
    typeid(int X::*) == frm.target_type();
113
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.