Daily bump.
[gcc.git] / gcc / testsuite / g++.dg / analyzer / new-vs-malloc.C
blob943ffe03cbfe46298e7f701becbf758bee9e686f
1 /* { dg-skip-if "requires hosted libstdc++ for cstdlib free" { ! hostedlib } } */
3 #include <cstdlib>
5 struct s {};
7 void test_1 ()
9   s *p = new s; // { dg-message "allocated here \\(expects deallocation with 'delete'\\)"
10   free (p); // { dg-warning "'p' should have been deallocated with 'delete' but was deallocated with 'free'" }
13 void test_2 ()
15   char *p = new char[16]; // { dg-message "allocated here \\(expects deallocation with 'delete\\\[\\\]'\\)"
16   free (p); // { dg-warning "'p' should have been deallocated with 'delete\\\[\\\]' but was deallocated with 'free'" }
19 void test_3 ()
21   char *p = (char *)malloc (16); // { dg-message "allocated here \\(expects deallocation with 'free'\\)"
22   delete[] p; // { dg-warning "'p' should have been deallocated with 'free' but was deallocated with 'delete\\\[\\\]'" }