Mercurial > hg > CbC > CbC_gcc
comparison gcc/testsuite/g++.dg/tree-ssa/pr81702.C @ 131:84e7813d76e9
gcc-8.2
author | mir3636 |
---|---|
date | Thu, 25 Oct 2018 07:37:49 +0900 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
111:04ced10e8804 | 131:84e7813d76e9 |
---|---|
1 // { dg-do compile } | |
2 // { dg-options "-O2" } | |
3 | |
4 namespace std { | |
5 struct type_info | |
6 { | |
7 virtual bool __do_catch(const type_info *__thr_type, void **__thr_obj, | |
8 unsigned __outer) const; | |
9 }; | |
10 } | |
11 | |
12 template< typename VALUE_T, typename TYPE > | |
13 struct List_policy | |
14 { | |
15 typedef VALUE_T *Value_type; | |
16 typedef TYPE **Type; | |
17 typedef TYPE *Head_type; | |
18 typedef TYPE Item_type; | |
19 }; | |
20 | |
21 template< typename POLICY > | |
22 class List | |
23 { | |
24 public: | |
25 typedef typename POLICY::Value_type Value_type; | |
26 class Iterator | |
27 { | |
28 typedef typename POLICY::Type Internal_type; | |
29 public: | |
30 typedef typename POLICY::Value_type value_type; | |
31 typedef typename POLICY::Value_type Value_type; | |
32 Value_type operator -> () const { return static_cast<Value_type>(*_c); } | |
33 Internal_type _c; | |
34 }; | |
35 Iterator begin() { return Iterator(); } | |
36 Iterator end() { return Iterator(); } | |
37 typename POLICY::Head_type _f; | |
38 }; | |
39 | |
40 template<typename ELEM_TYPE> class H_list_item_t { }; | |
41 | |
42 template< typename T, typename POLICY > | |
43 class H_list : public List<POLICY> | |
44 { | |
45 public: | |
46 typedef typename POLICY::Item_type Item; | |
47 typedef List<POLICY> Base; | |
48 typedef typename Base::Iterator Iterator; | |
49 Iterator insert(T *e, Iterator const &pred) | |
50 { | |
51 Item **x = &this->_f; | |
52 *x = static_cast<Item*>(e); | |
53 return Iterator(); | |
54 } | |
55 }; | |
56 | |
57 template< typename T > | |
58 struct H_list_t : H_list<T, List_policy< T, H_list_item_t<T> > > | |
59 { | |
60 H_list_t(bool b) : H_list<T, List_policy< T, H_list_item_t<T> > >(b) {} | |
61 }; | |
62 | |
63 template< typename BASE, typename MATCH_RESULT > | |
64 struct Type_matcher : H_list_item_t<BASE> | |
65 { | |
66 explicit Type_matcher(std::type_info const *type); | |
67 typedef MATCH_RESULT Match_result; | |
68 | |
69 private: | |
70 std::type_info *_type; | |
71 typedef H_list_t<BASE> List; | |
72 typedef typename List::Iterator Iterator; | |
73 static List _for_type; | |
74 }; | |
75 | |
76 template< typename BASE, typename MR > | |
77 Type_matcher<BASE, MR>::Type_matcher(std::type_info const *t) | |
78 { | |
79 Iterator c = _for_type.begin(); | |
80 t->__do_catch(c->_type, 0, 0); | |
81 _for_type.insert(static_cast<BASE*>(this), _for_type.begin()); | |
82 } | |
83 | |
84 template< typename VI, typename HW > | |
85 class Fa : public Type_matcher<Fa<VI, HW>, VI*> | |
86 { | |
87 public: | |
88 typedef Fa<VI, HW> Self; | |
89 virtual VI *do_match(HW *f) = 0; | |
90 explicit Fa(std::type_info const *type) : Type_matcher<Self, VI*>(type) {} | |
91 }; | |
92 | |
93 class Res {}; | |
94 typedef Fa<Res, Res> R_fac; | |
95 | |
96 template< typename VI, typename HW_BASE, typename HW, typename BASE > | |
97 class Fa_t : public BASE | |
98 { | |
99 public: | |
100 Fa_t() : BASE(&typeid(HW)) {} | |
101 VI *do_match(HW_BASE *) { return 0; } | |
102 }; | |
103 | |
104 template< typename VI, typename HW > | |
105 class Resource_factory_t : public Fa_t<VI, Res, HW, R_fac > {}; | |
106 | |
107 class Foo {}; | |
108 class Foo2; | |
109 class Foo3 : public Res {}; | |
110 Resource_factory_t<Foo3, Foo> _x; |