Fortran: Fix PR 47485.
[gcc.git] / gcc / testsuite / g++.dg / analyzer / vfunc-3.C
blobaaaf37603cf22bb8eb9438ac0987059341dc079e
1 /* { dg-skip-if "requires hosted libstdc++ for cstdlib malloc" { ! hostedlib } } */
3 #include <cstdlib>
5 struct A
7     virtual int foo (void) 
8     {
9         return 42;
10     }
13 struct B: public A
15     int *ptr;
16     void alloc ()
17     {
18         ptr = (int*)malloc(sizeof(int));
19     }
20     int foo (void) 
21     { 
22         free(ptr); /* { dg-warning "double-'free' of 'b.B::ptr'" } */
23         return 0;
24     }
27 int test ()
29     struct B b, *bptr=&b;
30     b.alloc ();
31     bptr->foo ();  /* { dg-message "\\(6\\) calling 'B::foo' from 'test'" "event 6" } */
32     /* { dg-message "\\(9\\) returning to 'test' from 'B::foo'" "event 9" { target *-*-* } .-1 } */
33     return bptr->foo ();