Skip analyzer strndup test on hppa*-*-hpux*
[official-gcc.git] / gcc / testsuite / gcc.dg / analyzer / strndup-1.c
blob85ccae85d832c7aa74394577a4f6f4928e08a5f4
1 /* { dg-skip-if "no strndup in libc" { *-*-darwin[789]* *-*-darwin10* hppa*-*-hpux* *-*-mingw* *-*-vxworks* } } */
3 #include <string.h>
4 #include <stdlib.h>
6 extern void requires_nonnull (void *ptr)
7 __attribute__((nonnull));
9 void test_1 (const char *s)
11 char *p = strndup (s, 42); /* { dg-message "allocated here" } */
12 } /* { dg-warning "leak of 'p'" } */
14 void test_2 (const char *s)
16 char *p = strndup (s, 42);
17 free (p);
19 void test_3 (const char *s)
21 char *p = strndup (s, 42); /* { dg-message "this call could return NULL" } */
22 requires_nonnull (p); /* { dg-warning "use of possibly-NULL 'p'" } */