OSDN Git Service

2010-10-05 Richard Guenther <rguenther@suse.de>
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / g++.dg / torture / pr45877.C
1 // { dg-do compile }
2
3 namespace std __attribute__ ((__visibility__ ("default")))
4 {
5   typedef __SIZE_TYPE__ size_t;
6   template<typename _Alloc>     class allocator;
7   template<class _CharT>     struct char_traits;
8   template<typename _CharT, typename _Traits = char_traits<_CharT>,
9       typename _Alloc = allocator<_CharT> >
10           class basic_string;
11   typedef basic_string<char> string;
12   template<class _T1, class _T2>     struct pair     { };
13   template<typename _Tp>     class allocator    { };
14   template<typename _Arg1, typename _Arg2, typename _Result>
15       struct binary_function     {
16           typedef _Arg1 first_argument_type;
17           typedef _Arg2 second_argument_type;
18           typedef _Result result_type;
19       };
20   template<typename _CharT, typename _Traits, typename _Alloc>
21   class basic_string {
22   public:
23       basic_string(const _CharT* __s, const _Alloc& __a = _Alloc());
24   };
25   class type_info   {
26   public:
27       const char* name() const;
28   };
29   extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__, __artificial__))
30   void * memcpy (void *__restrict __dest, __const void *__restrict __src, size_t __len) throw ()
31   {
32       return __builtin___memcpy_chk (__dest, __src, __len, __builtin_object_size (__dest, 0));
33   }
34   template <typename _Key, typename _Tp >
35   class map {
36       typedef _Key key_type;
37       typedef _Tp mapped_type;
38   public:
39       mapped_type&       operator[](const key_type& __k);
40   };
41 }
42 class CodeAlloc { };
43 using namespace std;
44 typedef void *Stack;
45 class basicForEachType;
46 typedef const basicForEachType * aType;
47 extern map<const string,basicForEachType *> map_type;
48 class AnyTypeWithOutCheck { };
49 typedef AnyTypeWithOutCheck AnyType;
50 template<typename T> AnyTypeWithOutCheck inline SetAny(const T & x)
51 {
52   AnyTypeWithOutCheck any;
53   memcpy(&any,&x,sizeof(x));
54 }
55 template<typename T> const T& GetAny(const AnyTypeWithOutCheck & x);
56 class E_F0;
57 class C_F0;
58 class Polymorphic;
59 typedef E_F0 * Expression;
60 class basicAC_F0;
61 extern Polymorphic * TheOperators, * TheRightOperators;
62 class basicForEachType : public CodeAlloc {
63 public:
64     virtual C_F0 CastTo(const C_F0 & e) const ;
65 };
66 class E_F0 :public CodeAlloc    {
67 public:
68     virtual AnyType operator()(Stack) const =0;
69 };
70 class E_F0mps : public E_F0 {
71 };
72 class ArrayOfaType : public CodeAlloc{
73 protected:
74     aType * t;
75 };
76 class OneOperator : public ArrayOfaType {
77 public:
78     OneOperator(aType rr,aType a,aType b);
79     virtual E_F0 * code(const basicAC_F0 &) const =0;
80 };
81 class Polymorphic: public E_F0mps {
82 public:
83     void Add(const char * op,OneOperator * p0 ,OneOperator * p1=0) const;
84 };
85 class C_F0 {
86 public:
87     operator E_F0 * () const;
88 };
89 class basicAC_F0 {
90 public:
91     const C_F0 & operator [] (int i) const;
92 };
93 struct OneBinaryOperatorMI { };
94 struct evalE_F2 { };
95 template<typename C,class MI=OneBinaryOperatorMI,class MIx=evalE_F2 >
96 class OneBinaryOperator : public OneOperator
97 {
98   typedef typename C::result_type R;
99   typedef typename C::first_argument_type A;
100   typedef typename C::second_argument_type B;
101   aType t0,t1;
102   class Op : public E_F0 {
103       Expression a,b;
104   public:
105       AnyType operator()(Stack s) const {
106           return SetAny<R>(static_cast<R>(C::f( GetAny<A>((*a)(s)),
107                                                 GetAny<B>((*b)(s)))));
108       }
109       Op(Expression aa,Expression bb) : a(aa),b(bb) { }
110   };
111 public:
112   E_F0 * code(const basicAC_F0 & args) const   {
113       return new Op(t0->CastTo(args[0]),t1->CastTo(args[1]));
114   }
115   OneBinaryOperator()
116       : OneOperator(map_type[typeid(R).name()],
117                     map_type[typeid(A).name()],
118                     map_type[typeid(B).name()]), t0(t[0]), t1(t[1]) { }
119 };
120 struct NothingType { };
121 class ShapeOfArray{ };
122 template<class R> class KN_: public ShapeOfArray { };
123 template <class T> struct affectation: binary_function<T, T, T> { };
124 template<class K,class L,class OP> struct set_A_BI
125 : public binary_function<KN_<K>,pair<KN_<K>, KN_<L> > *,KN_<K> >
126 {
127   static KN_<K> f(const KN_<K> & a, pair<KN_<K>, KN_<L> > * const & b);
128 };
129 template<class K,class L,class OP> struct set_AI_B
130 : public binary_function<pair<KN_<K>, KN_<L> > * ,KN_<K>, NothingType >
131 {
132   static NothingType f( pair<KN_<K>, KN_<L> > * const & b,const KN_<K> & a);
133 };
134 template<class K,class Z> void ArrayOperator()
135 {
136   TheOperators->Add("=", new OneBinaryOperator<set_A_BI< K,Z,affectation<K> > >,
137                     new OneBinaryOperator<set_AI_B< K,Z,affectation<K> > >);
138 }
139 void initArrayOperatorlong() {
140     ArrayOperator<long,long>();
141 }