[C++ PATCH] Deprecate -ffriend-injection
[official-gcc.git] / gcc / testsuite / g++.dg / tree-ssa / pr27548.C
blobcbe7929aefea3a3d3b43e8a54665b0340f2e162a
1 // PR tree-optimization/27548
2 // { dg-do compile }
3 // { dg-options "-O1" }
4 // { dg-additional-options "-Wno-return-type" }
6 namespace Gambit
8   template < class T > class Array
9   {
10   protected:int mindex, maxdex;
11     T *data;
12     int InsertAt (const T & t, int n)
13     {
14       T *new_data = new T[++this->maxdex - this->mindex + 1] - this->mindex;
15       int i;
16       for (i = this->mindex; i <= n - 1; i++)
17           new_data[i] = this->data[i];
18         new_data[i++] = t;
19     }
20   public:   Array (unsigned int len = 0):mindex (1), maxdex (len),
21       data ((len) ? new T[len] -
22             1 : 0)
23     {
24     }
25     virtual ~ Array ()
26     {
27       if (maxdex >= mindex)
28         delete[](data + mindex);
29     }
30     const T & operator[] (int index) const
31     {
32     }
33     int Append (const T & t)
34     {
35       return InsertAt (t, this->maxdex + 1);
36     }
37   };
40 class gIndexOdometer
42 private:Gambit::Array < int >MinIndices;
43     Gambit::Array < int >CurIndices;
44     gIndexOdometer (const Gambit::Array < int >, const Gambit::Array < int >);
45   void SetIndex (const int &, const int &);
46   int NoIndices () const;
47   gIndexOdometer AfterExcisionOf (int &) const;
49 gIndexOdometer
50 gIndexOdometer::AfterExcisionOf (int &to_be_zapped) const
52   Gambit::Array < int >NewMins, NewMaxs;
53   int i;
54   for (i = 1; i <= NoIndices (); i++)
55     {
56       NewMins.Append (MinIndices[i]);
57     }
58   gIndexOdometer NewOdo (NewMins, NewMaxs);
59   for (i = 1; i < to_be_zapped; i++)
60     NewOdo.SetIndex (i, CurIndices[i]);