summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.old-deja/g++.law/operators32.C
blob: 20d148dd544988bd3bb5562ea9d734537cbbbd92 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// { dg-do assemble  }
// GROUPS passed operators
#include <iostream>

//
// ffrees space allocated for N-D array
//

template <class T>
void ffree(long rows, T** array) // { dg-message "note" }
{
for( long i = 0; i < rows; i++ )
  delete [] array[i];                   // delete row
delete [] array;                        // delete outer array
}

template <class T>
T* allocate1d(long size, T*& array)
{
return array = new T[size];
}

template <class T>
T** allocate2d(long d1, long d2, T**& array) // { dg-message "note" }
{
if( allocate1d(d1, array) != 0 )
  {
  for( long i = 0; i < d1; i++ )
    {
    if( allocate1d(d2, array[i]) == 0 )
      {
      ffree(i,array);
      return array;
      }
    }
  }
return array;
}

int main()
{
long d1 = 3, d2 = 4;
class foo
{
public:
foo() {std::cout << "foo created" << std::endl; }

~foo() {std::cout << "foo deleted" << std::endl; }
};

foo **f2;
allocate2d(d1, d2, f2);// { dg-error "" }  type.*// ERROR -    trying to.*
// { dg-message "candidate" "candidate note" { target *-*-* } 52 }
ffree(d1, f2);// { dg-error "" }  type.*// ERROR -    trying to.*
// { dg-message "candidate" "candidate note" { target *-*-* } 54 }

}