Home | History | Annotate | Download | only in jni
      1 // PR c++/15097
      2 // { dg-do run }
      3 
      4 typedef __SIZE_TYPE__ size_t;
      5 
      6 extern "C" void * malloc (size_t);
      7 extern "C" void free (void *);
      8 extern "C" void abort(void);
      9 
     10 void *saved;
     11 
     12 void * operator new (size_t size)
     13 {
     14   void *p = malloc (size);
     15   saved = p;
     16   return p;
     17 }
     18 
     19 void operator delete (void *p)
     20 {
     21   if (p != saved)
     22     abort ();
     23   free (p);
     24 }
     25 
     26 struct B1
     27 {
     28     virtual ~B1 () throw() {}
     29     B1 (){}
     30     int x;
     31 };
     32 struct B2
     33 {
     34     virtual ~B2 () throw() {}
     35     B2 (){}
     36     int x;
     37 };
     38 struct D : B1, B2
     39 {
     40     D (){}
     41     ~D () throw() {}
     42     int y;
     43 };
     44 void f1 (D*);
     45 void f2 (B2*);
     46 void f3 (B1*);
     47 int main (void)
     48 {
     49     f1 (::new D);
     50     f2 (::new D);
     51     f3 (::new D);
     52 }
     53 void f1 ( D* p) { ::delete p; }
     54 void f2 (B2* p) { ::delete p; }
     55 void f3 (B1* p) { ::delete p; }
     56