Clean up some minor white space issues in trans-decl.c and trans-expr.c
[official-gcc.git] / gcc / testsuite / g++.dg / torture / pr68220.C
blob3b27653219cdff7b6e1586f6462de07af45b121f
1 // { dg-do compile }
2 namespace mpl {
3 template <typename, typename = int> struct lambda;
4 template <typename T3> struct if_ { typedef T3 type; };
5 template <int> struct arg {
6   template <typename U1, typename> struct apply { typedef U1 type; };
7 };
8 template <typename> struct begin_impl;
9 template <typename Sequence> struct begin {
10   typedef typename Sequence::tag tag_;
11   typedef typename begin_impl<tag_>::template apply<Sequence>::type type;
13 template <typename> struct O1_size_impl;
15 template <long N> struct long_ { static const long value = N; };
16 namespace mpl {
17 template <typename Sequence>
18 struct O1_size
19     : O1_size_impl<typename Sequence::tag>::template apply<Sequence> {};
20 typedef arg<1> _1;
21 template <typename T> struct protect : T {};
22 template <typename F> struct apply_wrap1 : F::template apply<int> {};
23 template <typename F, typename T1, typename T2>
24 struct apply_wrap2 : F::template apply<T1, T2> {};
25 template <typename F> struct apply_wrap5 : F::template apply<int> {};
26 template <typename, typename, typename, typename, typename, typename>
27 struct resolve_bind_arg;
28 template <typename T, typename> struct replace_unnamed_arg { typedef T type; };
29 template <typename F, typename> struct bind1 {
30   template <typename> struct apply {
31     typedef typename apply_wrap1<F>::type type;
32   };
34 template <typename F, typename T1, typename U1, typename U2, typename U3,
35           typename U4, typename U5>
36 struct resolve_bind_arg<bind1<F, T1>, U1, U2, U3, U4, U5> {
37   typedef typename apply_wrap5<bind1<F, T1>>::type type;
39 template <typename F, typename, typename T2> struct bind2 {
40   template <typename U1, typename U2> struct apply {
41     typedef resolve_bind_arg<typename replace_unnamed_arg<T2, arg<1>>::type, U1,
42                              U2, int, int, int> t2;
43     typedef typename apply_wrap2<F, typename U1::type, typename t2::type>::type
44         type;
45   };
47 template <typename T> struct quote_impl { typedef T type; };
48 template <template <typename> class F> struct quote1 {
49   template <typename> struct apply : quote_impl<F<int>> {};
51 template <typename T, typename> struct lambda {
52   typedef T type;
53   typedef arg<1> result_;
55 template <typename, template <typename> class, typename> struct le_result1;
56 template <template <typename> class F, typename L1>
57 struct le_result1<int, F, L1> {
58   typedef protect<bind1<quote1<F>, typename L1::result_>> type;
60 template <template <typename> class F, typename T1, typename Tag>
61 struct lambda<F<T1>, Tag> {
62   typedef typename le_result1<int, F, lambda<T1>>::type type;
64 template <int, typename, typename, typename> struct iter_fold_impl;
65 template <typename First, typename State, typename ForwardOp>
66 struct iter_fold_impl<1, First, State, ForwardOp> {
67   typedef typename apply_wrap2<ForwardOp, State, First>::type state;
69 template <typename Sequence, typename State, typename ForwardOp>
70 struct iter_fold {
71   typedef typename iter_fold_impl<O1_size<Sequence>::value,
72                                   typename begin<Sequence>::type, State,
73                                   ForwardOp>::state type;
75 template <typename> struct deref;
76 template <typename> struct push_front_impl;
77 template <typename T> struct l_item {
78   typedef int tag;
79   typedef l_item type;
80   typedef long_<1> size;
81   typedef T item;
83 struct l_end {
84   typedef int tag;
85   typedef l_end type;
87 template <> struct push_front_impl<int> {
88   template <typename, typename T> struct apply { typedef l_item<T> type; };
90 template <> struct O1_size_impl<int> {
91   template <typename> struct apply : l_item<int>::size {};
93 template <typename> struct l_iter;
94 template <typename Node> struct deref<l_iter<Node>> {
95   typedef typename Node::item type;
97 template <> struct begin_impl<int> {
98   template <typename List> struct apply {
99     typedef l_iter<typename List::type> type;
100   };
102 template <typename> struct list : l_item<int> {};
104 template <typename T> T &cast_storage(void *storage) {
105   return *static_cast<T *>(storage);
107 struct symbol;
108 struct visitation_impl_step {
109   typedef symbol type;
111 template <typename Visitor, typename VoidPtrCV, typename T>
112 void visitation_impl_invoke_impl(int, Visitor visitor, VoidPtrCV storage, T *) {
113   visitor.internal_visit(cast_storage<T>(storage), 1);
115 int visitation_impl_invoke_internal_which, visitation_impl_logical_which;
116 template <typename Visitor, typename VoidPtrCV, typename T,
117           typename NoBackupFlag>
118 void visitation_impl_invoke(Visitor visitor, VoidPtrCV storage, T t,
119                             NoBackupFlag, int) {
120   visitation_impl_invoke_impl(visitation_impl_invoke_internal_which, visitor,
121                               storage, t);
123 template <typename Which, typename step0, typename Visitor, typename VoidPtrCV,
124           typename NoBackupFlag>
125 void visitation_impl(int, Visitor visitor, VoidPtrCV storage, int,
126                      NoBackupFlag no_backup_flag, Which, step0 *) {
127   switch (visitation_impl_logical_which)
128   case 0:
129   visitation_impl_invoke(visitor, storage,
130                          static_cast<typename step0::type *>(0), no_backup_flag,
131                          1);
133 template <long N> struct size_t { static const long value = N; };
134 struct aligned_storage_imp {};
135 template <long> class aligned_storage : aligned_storage_imp {
136 public:
137   void *address() { return static_cast<aligned_storage_imp *>(this); }
139 namespace mpl {
140 template <typename> struct less;
141 template <typename> struct select_max {
142   template <typename OldIterator, typename> struct apply {
143     typedef OldIterator type;
144   };
146 template <typename Sequence, typename Predicate = less<arg<11>>>
147 struct max_element : iter_fold<Sequence, typename begin<Sequence>::type,
148                                protect<select_max<Predicate>>> {};
149 template <typename Sequence = int, typename T = int>
150 struct push_front
151     : push_front_impl<typename Sequence::tag>::template apply<Sequence, T> {};
152 template <> struct push_front<> {
153   template <typename T1, typename T2> struct apply : push_front<T1, T2> {};
155 template <typename> struct sizeof_ : size_t<sizeof(int)> {};
156 template <long, typename, typename, typename, typename>
157 struct reverse_fold_impl;
158 template <typename First, typename State, typename BackwardOp,
159           typename ForwardOp>
160 struct reverse_fold_impl<1, First, State, BackwardOp, ForwardOp> {
161   typedef First iter0;
162   typedef typename apply_wrap2<
163       BackwardOp,
164       typename apply_wrap2<ForwardOp, State, typename deref<iter0>::type>::type,
165       typename deref<iter0>::type>::type state;
167 template <typename Sequence, typename State, typename BackwardOp,
168           typename ForwardOp = arg<1>>
169 struct reverse_fold {
170   typedef typename reverse_fold_impl<O1_size<Sequence>::value,
171                                      typename begin<Sequence>::type, State,
172                                      BackwardOp, ForwardOp>::state type;
174 template <typename> struct inserter {
175   typedef mpl::l_end state;
176   typedef mpl::push_front<> operation;
178 template <typename Seq, typename Op, typename In>
179 struct reverse_transform1_impl
180     : reverse_fold<Seq, typename In::state,
181                    bind2<typename lambda<typename In::operation>::type, _1,
182                          bind1<typename lambda<Op>::type, arg<2>>>> {};
183 template <typename P1, typename P2>
184 struct transform1
185     : if_<reverse_transform1_impl<P1, P2, inserter<push_front<>>>>::type {};
187 template <typename, typename> struct max_value {
188   typedef mpl::transform1<mpl::list<symbol>, mpl::sizeof_<mpl::arg<1>>>::type
189       transformed_;
190   typedef mpl::max_element<transformed_>::type max_it;
191   typedef mpl::deref<max_it>::type type;
193 template <typename> struct make_storage {
194   typedef max_value<int, mpl::sizeof_<int>>::type max_size;
195   typedef aligned_storage<max_size::value> type;
197 struct destroyer {
198   template <typename T> void internal_visit(T &operand, int) { operand.~T(); }
200 template <typename, typename...> class variant {
201   typedef int internal_types;
202   int which_;
203   make_storage<internal_types>::type storage_;
204 public:
205   ~variant() {
206     destroyer visitor;
207     internal_apply_visitor(visitor);
208   }
209   template <typename Visitor, typename VoidPtrCV>
210   void internal_apply_visitor_impl(int internal_which, int, Visitor visitor,
211                                    VoidPtrCV storage) {
212     visitation_impl(internal_which, visitor, storage, int(), int(),
213                     static_cast<int>(0),
214                     static_cast<visitation_impl_step *>(0));
215   }
216   int internal_apply_visitor___trans_tmp_1;
217   template <typename Visitor> void internal_apply_visitor(Visitor visitor) {
218     internal_apply_visitor_impl(which_, internal_apply_visitor___trans_tmp_1,
219                                 visitor, storage_.address());
220   }
222 struct symbol {
223   virtual ~symbol();
225 using Identifier = variant<int>;
226 struct Fragment {
227   virtual void foo() const = 0;
228   virtual ~Fragment();
230 struct ProcFrag : Fragment {
231   ~ProcFrag() {}
232   void foo() const;
233   Identifier id;
235 struct Fragments {
236   ~Fragments() { delete x; }
237   Fragment *x;
238 } fragments;