2018-10-23 Richard Biener <rguenther@suse.de>
[official-gcc.git] / gcc / testsuite / g++.dg / tree-ssa / pr27291.C
blob24f440dde063b6fe14ee0d1ba088bcb5e716252e
1 /* { dg-do compile } */
2 /* { dg-options "-O2" } */
3 /* { dg-additional-options "-Wno-return-type" } */
5 namespace std
7   template < class _T1, class _T2 > struct pair
8   {
9   };
11 extern "C"
13   extern "C"
14   {
15     typedef int int32_t __attribute__ ((__mode__ (__SI__)));
16     struct _pthread_fastlock
17     {
18     }
19     pthread_mutexattr_t;
20   }
22 namespace std
24   struct __numeric_limits_base
25   {
26   };
27     template < typename _Tp >
28     struct numeric_limits:public __numeric_limits_base
29   {
30     static const bool is_integer = true;
31   };
33 typedef unsigned int uint32_t;
34 namespace std
36   template < typename _Alloc > class allocator;
37   template < class _CharT > struct char_traits;
38     template < typename _CharT, typename _Traits =
39     char_traits < _CharT >, typename _Alloc =
40     allocator < _CharT > >class basic_string;
41   typedef basic_string < char >string;
43 namespace __gnu_cxx
45   template < typename _Tp > class new_allocator
46   {
47   };
49 namespace std
51   template < typename _Tp > class allocator:public __gnu_cxx::new_allocator <
52     _Tp >
53   {
54   };
55   template < typename _CharT, typename _Traits,
56     typename _Alloc > class basic_string
57   {
58   public:inline basic_string ();
59     basic_string (const _CharT * __s, const _Alloc & __a = _Alloc ());
60   };
62 namespace boost
64   template < class T > class integer_traits:public std::numeric_limits < T >
65   {
66   };
67   namespace detail
68   {
69     template < class T, T min_val, T max_val > class integer_traits_base
70     {
71     };
72   }
73   template <> class integer_traits < int >:public std::numeric_limits < int >,
74     public detail::integer_traits_base < int, (-2147483647 - 1), 2147483647 >
75   {
76   };
77   namespace random
78   {
79     template < class IntType, IntType m > class const_mod
80     {
81     public:static IntType add (IntType x, IntType c)
82       {
83       }
84       static IntType mult (IntType a, IntType x)
85       {
86         return mult_schrage (a, x);
87       }
88       static IntType mult_add (IntType a, IntType x, IntType c)
89       {
90         return add (mult (a, x), c);
91       }
92       static IntType mult_schrage (IntType a, IntType value)
93       {
94         for (;;)
95           {
96             if (value > 0)
97               break;
98             value += m;
99           }
100       }
101     };
102     template < class IntType, IntType a, IntType c, IntType m,
103       IntType val > class linear_congruential
104     {
105     public:typedef IntType result_type;
106       static const IntType modulus = m;
107     explicit linear_congruential (IntType x0 = 1):_modulus (modulus),
108         _x (_modulus ? (x0 % _modulus) :
109             x0)
110       {
111       }
112       IntType operator    () ()
113       {
114         _x = const_mod < IntType, m >::mult_add (a, _x, c);
115       }
116     private:IntType _modulus;
117       IntType _x;
118     };
119   }
120   typedef random::linear_congruential < int32_t, 16807, 0, 2147483647,
121     1043618065 > minstd_rand0;
122   namespace random
123   {
124     namespace detail
125     {
126       template < class T > struct ptr_helper
127       {
128         typedef T value_type;
129         typedef T & reference_type;
130         typedef const T & rvalue_type;
131         static reference_type ref (T & r)
132         {
133         }
134       };
135         template < class T > struct ptr_helper <T & >
136       {
137         typedef T value_type;
138         typedef T & rvalue_type;
139       };
140     }
141   }
142   template < class UniformRandomNumberGenerator, class RealType =
143     double >class uniform_01
144   {
145   public:typedef UniformRandomNumberGenerator base_type;
146     typedef RealType result_type;
147     explicit uniform_01 (base_type rng):_rng (rng),
148       _factor (result_type (1) /
149                (result_type ((_rng.max) () - (_rng.min) ()) +
150                 result_type (std::numeric_limits <
151                              base_result >::is_integer ? 1 : 0)))
152     {
153     }
154     result_type operator    () ()
155     {
156       return result_type (_rng () - (_rng.min) ()) * _factor;
157     }
158   private:typedef typename base_type::result_type base_result;
159     base_type _rng;
160     result_type _factor;
161   };
162   namespace random
163   {
164     namespace detail
165     {
166       template < class UniformRandomNumberGenerator >
167         class pass_through_engine
168       {
169       private:typedef ptr_helper < UniformRandomNumberGenerator >
170           helper_type;
171       public:typedef typename helper_type::value_type base_type;
172         typedef typename base_type::result_type result_type;
173         explicit pass_through_engine (UniformRandomNumberGenerator
174                                       rng):_rng (static_cast <
175                                                  typename helper_type::
176                                                  rvalue_type > (rng))
177         {
178         }
179         result_type min () const
180         {
181         }
182         result_type max () const
183         {
184         }
185         base_type & base ()
186         {
187         }
188         result_type operator    () ()
189         {
190           return base ()();
191         }
192       private:UniformRandomNumberGenerator _rng;
193       };
194     }
195     template < class RealType, int w, unsigned int p,
196       unsigned int q > class lagged_fibonacci_01
197     {
198     public:typedef RealType result_type;
199       static const unsigned int long_lag = p;
200         lagged_fibonacci_01 ()
201       {
202         seed ();
203       }
204     public:void seed (uint32_t value = 331u)
205       {
206         minstd_rand0 intgen (value);
207         seed (intgen);
208       }
209       template < class Generator > void seed (Generator & gen)
210       {
211         typedef detail::pass_through_engine < Generator & >ref_gen;
212         uniform_01 < ref_gen, RealType > gen01 =
213           uniform_01 < ref_gen, RealType > (ref_gen (gen));
214         for (unsigned int j = 0; j < long_lag; ++j)
215           x[j] = gen01 ();
216       }
217       RealType x[long_lag];
218     };
219   }
220   typedef random::lagged_fibonacci_01 < double, 48, 607,
221     273 > lagged_fibonacci607;
222   namespace random
223   {
224     namespace detail
225     {
226       template < bool have_int, bool want_int > struct engine_helper;
227         template <> struct engine_helper <true, true >
228       {
229         template < class Engine, class DistInputType > struct impl
230         {
231           typedef pass_through_engine < Engine > type;
232         };
233       };
234     }
235   }
236   template < class Engine, class Distribution > class variate_generator
237   {
238   private:typedef random::detail::pass_through_engine < Engine >
239       decorated_engine;
240   public:typedef typename decorated_engine::base_type engine_value_type;
241     typedef Distribution distribution_type;
242   variate_generator (Engine e, Distribution d):_eng (decorated_engine (e)),
243       _dist (d)
244     {
245     }
246   private:enum
247     {
248       have_int =
249         std::numeric_limits <
250         typename decorated_engine::result_type >::is_integer, want_int =
251         std::numeric_limits < typename Distribution::input_type >::is_integer
252     };
253     typedef typename random::detail::engine_helper < have_int,
254       want_int >::template impl < decorated_engine,
255       typename Distribution::input_type >::type internal_engine_type;
256     internal_engine_type _eng;
257     distribution_type _dist;
258   };
259   template < class RealType = double >class uniform_real
260   {
261   public:typedef RealType input_type;
262   };
264 namespace alps
266   class BufferedRandomNumberGeneratorBase
267   {
268   };
269     template < class RNG >
270     class BufferedRandomNumberGenerator:public
271     BufferedRandomNumberGeneratorBase
272   {
273   public: BufferedRandomNumberGenerator ():rng_ (), gen_ (rng_,
274                    boost::
275                    uniform_real <> ())
276     {
277     }
278   protected:  RNG rng_;
279     boost::variate_generator < RNG &, boost::uniform_real <> >gen_;
280   };
282 namespace boost
284   namespace detail
285   {
286     class sp_counted_base
287     {
288     };
289     class shared_count
290     {
291     private:sp_counted_base * pi_;
292     public:shared_count ():pi_ (0)
293       {
294       }
295       template < class Y > explicit shared_count (Y * p):pi_ (0)
296       {
297       }
298     };
299   }
300   template < class T > class shared_ptr
301   {
302   public:typedef T element_type;
303   template < class Y > explicit shared_ptr (Y * p):px (p), pn (p)
304     {
305     }
306     T *px;
307     detail::shared_count pn;
308   };
310 namespace std
312   template < typename _Key, typename _Tp, typename _Compare =
313     std::allocator < std::pair < const _Key, _Tp > > > class map
314   {
315   public:typedef _Key key_type;
316     typedef _Tp mapped_type;
317       mapped_type & operator[] (const key_type & __k)
318     {
319     }
320   };
322 namespace alps
324   namespace detail
325   {
326     template < class BASE > class abstract_creator
327     {
328     public:typedef BASE base_type;
329       virtual base_type *create () const = 0;
330     };
331       template < class BASE,
332       class T > class creator:public abstract_creator < BASE >
333     {
334     public:typedef BASE base_type;
335       base_type *create () const
336       {
337         return new T ();
338       }
339     };
340   }
341   template < class KEY, class BASE > class factory
342   {
343   public:typedef BASE base_type;
344     typedef KEY key_type;
345     typedef boost::shared_ptr < detail::abstract_creator < base_type >
346       >pointer_type;
347     template < class T > bool register_type (key_type k)
348     {
349       creators_[k] = pointer_type (new detail::creator < BASE, T > ());
350     }
351   private:typedef std::map < key_type, pointer_type > map_type;
352     map_type creators_;
353   };
354   class RNGFactory:public factory < std::string,
355     BufferedRandomNumberGeneratorBase >
356   {
357   public:RNGFactory ();
358   };
360 alps::RNGFactory::RNGFactory ()
362   register_type < BufferedRandomNumberGenerator < boost::lagged_fibonacci607 >
363     >("lagged_fibonacci607");