OSDN Git Service

91de03ee8fcad41def085f3538f93cb018414a42
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / g++.old-deja / g++.law / operators32.C
1 // { dg-do assemble  }
2 // GROUPS passed operators
3 #include <iostream>
4
5 //
6 // ffrees space allocated for N-D array
7 //
8
9 template <class T>
10 void ffree(long rows, T** array)
11 {
12 for( long i = 0; i < rows; i++ )
13   delete [] array[i];                   // delete row
14 delete [] array;                        // delete outer array
15 }
16
17 template <class T>
18 T* allocate1d(long size, T*& array)
19 {
20 return array = new T[size];
21 }
22
23 template <class T>
24 T** allocate2d(long d1, long d2, T**& array)
25 {
26 if( allocate1d(d1, array) != 0 )
27   {
28   for( long i = 0; i < d1; i++ )
29     {
30     if( allocate1d(d2, array[i]) == 0 )
31       {
32       ffree(i,array);
33       return array;
34       }
35     }
36   }
37 return array;
38 }
39
40 int main()
41 {
42 long d1 = 3, d2 = 4;
43 class foo
44 {
45 public:
46 foo() {std::cout << "foo created" << std::endl; }
47
48 ~foo() {std::cout << "foo deleted" << std::endl; }
49 };
50
51 foo **f2;
52 allocate2d(d1, d2, f2);// { dg-error "" }  type.*// ERROR -    trying to.*
53 ffree(d1, f2);// { dg-error "" }  type.*// ERROR -    trying to.*
54
55 }